Maybe the title is not so descriptive.
I’m working right with Galasoft MVVM framework, and I realized in my application I need all the time or use these data in the view models.
The data which I need is this Authentification model
- Username : string
- Password : string
- IsGuest : bool
I guess it is not a good idea and the best way to pass these data through navigation.
A few months ago, I was using Prism and I remember something called Container, where you can register and save your object in all the lifecycle of your application.
Another way which I was thinking is to save it in App class, but I’m not sure if this is a good idea.
By the way, I’m working on Metro UI applications.
Don’t store the data in the
Appbecause it is part of the View. To use it you would effectively have to reference the View from all of your ViewModels. A core principle of MVVM is that the Model(s) only have access to other Model items, the ViewModel has access to other ViewModels and the Model, and the View has access to ViewModelsThere are a couple of choices you could consider
Options 2 and 3 could make it easier to mock your authentication data for testing purposes if you use an
IAuthenticationDatainterface