I’ve to create a small windows application(no silverlight, no windows phone, no windows 8 app, …), and since I’ve some extra for this application, I decided to take the time to learn the MVVM pattern.
I read about it and I understood the principal part.
I found the MVVM Light Toolkit, but I find hard to start with. Except this page where I find the class names, I can’t find any documentation about this, some kind of “getting started” section.
I tried to start with that, but I can’t find:
- What is the
ViewModelLocator, and how should I use it - A simple example of a ViewModel, extending the
ViewModelBase(for example, I don’t know if I should callRaisePropertyChanging,RaisePropertyChanged, both, if I should put just the property name, … - Some example about how to use the
Messenger(in which part of the code I should register, examples of conditions)
After some search on the net, either I find informations for windows phone(with Page, …), either it’s years old topic.
So do you know where I can find this kind of information?
Thank you!
To answer your questions:
The ViewModelLocator is a class that allows you to expose your various models via properties, and do whatever initialization is required. You can then bind the DataContext of a page or control conveniently to a ViewModel.
Here is a similar question
Call RaisePropertyChanged([name-of-property-here]) to update your bindings.
Use the Messenger as a way to easily notify your page when the state of the application has changed, to display an error message when an error has occurred is a good example. To use Messenger, you can register in OnNavigatedTo
and don’t forget to unregister in OnNavigatedFrom