In the samples app, in the Putting Things Together section, the example follows a process whereby services are created, registered in the app.xaml.cs and then injected into the viewmodels via constructor injection.
On the Reddit Service example the SubredditWidgetViewModel gets the IRedditService from the IOC.Default instance
/// <summary>
/// Gets the <see cref="IRedditService"/> instance to use.
/// </summary>
private readonly IRedditService RedditService = Ioc.Default.GetRequiredService<IRedditService
The rest of the sample app doesnt mention really the IoC class at all, and the service is definitely not registered with it in the examples. In fact further down its registered in the app.xaml.cs.
This example should be reworked slightly to accept the IRedditService via constructor injection, like the PostWidgetViewModel.
Similarly, the SubredditWidgetViewModel should also be shown to be registered with the service collection too, for consistency
In the samples app, in the Putting Things Together section, the example follows a process whereby services are created, registered in the app.xaml.cs and then injected into the viewmodels via constructor injection.
On the Reddit Service example the
SubredditWidgetViewModel
gets theIRedditService
from the IOC.Default instanceThe rest of the sample app doesnt mention really the IoC class at all, and the service is definitely not registered with it in the examples. In fact further down its registered in the app.xaml.cs.
This example should be reworked slightly to accept the IRedditService via constructor injection, like the
PostWidgetViewModel
. Similarly, theSubredditWidgetViewModel
should also be shown to be registered with the service collection too, for consistency