CommunityToolkit / CommunityToolkit/MVVM-Samples

Docs - Services in "Putting things together"

Open
#34 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
1.4k
Forks
265
PR merge metrics
No merged PRs in 30d

Description

The [Putting things together](https://github.com/windows-toolkit/MVVM-Samples/blob/master/docs/mvvm/PuttingThingsTogether.md) page describes how to make and implement services, but it doesn't explain how to use them. The [Building the UI](https://github.com/windows-toolkit/MVVM-Samples/blob/master/docs/mvvm/PuttingThingsTogether.md) section gives a sample, but it doesn't work.

1. `App.Current` doesn't have a `Services` property. I discovered in #22 that you have to cast it like this `((App)Application.Current).Services` to access it.
2. The code included at the end of the previous section doesn't seem to set the `Services` property. When I tried the above fix in the constructor of my MainPage, `Services` was null.
3. `IServiceProvider` doesn't have a `GetService()` method in the latest version of `Microsoft.Extensions.DependencyInjection` (5.0.0). It seems to have been changed to `GetService(Type serviceType)`.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.