Skip to content

Commit 2f2b0f6

Browse files
committed
Added a note about DI support
1 parent ab65af3 commit 2f2b0f6

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

docs/mvvm/PuttingThingsTogether.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@ We now have a draft of our viewmodels ready, and we can start looking into the s
155155

156156
## Building the settings service
157157

158+
> [!NOTE]
159+
> The sample is built using the service locator pattern, but this is not the only possible pattern to use to manage service. The MVVM Toolkit also fully supports the dependency injection pattern, and you can choose the one you prefer depending on the architecture of your application, the available development time or personal preference.
160+
158161
Since we want some of our properties to be saved and persisted, we need a way for viewmodels to be able to interact with the application settings. We shouldn't use platform-specific APIs directly in our viewmodels though, as that would prevent us from having all our viewmodels in a portable, .NET Standard project. We can solve this issue by using services, and the `Ioc` class. The idea is to write interfaces that represent all the API surface that we need, and then to implement platform-specific types implementing this interface on all our application targets. The viewmodels will only interact with the interfaces, so they will not have any strong reference to any platform-specific type at all.
159162

160163
Here's a simple interface for a settings service:

samples/MvvmSampleUwp/MvvmSampleUwp/Assets/docs/PuttingThingsTogether.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ We now have a draft of our viewmodels ready, and we can start looking into the s
155155

156156
## Building the settings service
157157

158+
> **NOTE:** the sample is built using the service locator pattern, but this is not the only possible pattern to use to manage service. The MVVM Toolkit also fully supports the dependency injection pattern, and you can choose the one you prefer depending on the architecture of your application, the available development time or personal preference.
159+
158160
Since we want some of our properties to be saved and persisted, we need a way for viewmodels to be able to interact with the application settings. We shouldn't use platform-specific APIs directly in our viewmodels though, as that would prevent us from having all our viewmodels in a portable, .NET Standard project. We can solve this issue by using services, and the `Ioc` class. The idea is to write interfaces that represent all the API surface that we need, and then to implement platform-specific types implementing this interface on all our application targets. The viewmodels will only interact with the interfaces, so they will not have any strong reference to any platform-specific type at all.
159161

160162
Here's a simple interface for a settings service:

0 commit comments

Comments
 (0)