diff --git a/doc/Learn/Tutorials/DependencyInjection/HowTo-DependencyInjectionSetup.md b/doc/Learn/Tutorials/DependencyInjection/HowTo-DependencyInjectionSetup.md index e75baf3907..7eb5878385 100644 --- a/doc/Learn/Tutorials/DependencyInjection/HowTo-DependencyInjectionSetup.md +++ b/doc/Learn/Tutorials/DependencyInjection/HowTo-DependencyInjectionSetup.md @@ -60,21 +60,21 @@ Dependency Injection (DI) is an important design pattern for building loosely-co } } ``` -* For the dependency injection framework to handle instantiation of the service as a constructor argument, you must also register your view model with the `IServiceCollection`: +* If you are using not using [navigation](xref:Overview.Navigation), you have to register the view model to `IServiceCollection`, but we recommend using navigation and not manually register the view model as a service: ```cs private IHost Host { get; } = BuildAppHost(); private static IHost BuildAppHost() - { - return UnoHost + { + return UnoHost .CreateDefaultBuilder() .ConfigureServices(services => - { - // Register your services - services.AddSingleton(); + { + // Register your services + services.AddSingleton(); // Register view model services.AddTransient(); - }) + }) .Build(); } ```