How to manage view models in viewports?

fatih uyanık 80 Reputation points


I'm trying to learn the ViewModel pattern. I want to ask you about a subject that I cannot understand.

I am implementing Dependency Injection using the Microsoft.Extensions package. I recorded the database and message services I use. So far, no problem.

In my project I have view models that manage views. In some sources, it is recommended to register all these as services at the beginning of the application and use them through dependency. This doesn't seem right to me in terms of performance. The correct approach would be to save these view models as services or to manage them dynamically by creating instances through a central navigation class. Finally, use the navigation class by registering it as a service.

Can you guide me on this?


Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,710 questions
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,640 questions
{count} votes