MVVM stands for Model - View - ViewModel and it is a pattern used when dealing with views created (mainly) with WPF technology (even when it can be used with other technologies as well it is not so common).
As anyone can work out by its name it is composed by three elements:
To present the data available at the DataContext to the end user to allow him to interact with it.Design Tips
Avoid putting logic on the View even when XAML allows to do it. Prefer moving that logic to the ViewModel over adding it to the View because:
To model a business object containing the required data.Design Tips
As the model is only a representation of the data of a business entity (object) it should contain only properties containing object’s data and constructors.
Implementing INotifyPropertyChanged is right as we consider this part of the object’s responsibility.
To contain the logic that acts as a bridge between the View and the Model.Design Tips
Avoid putting too much logic inside the ViewModel and consider creating more classes (services, engines, etc.) if the ViewModel logic is too big to fit in one class.
Include always a reference to the model on the ViewModel.
The MVVM pattern provides the following benefits:
The next diagram shows the basic layers every MVVM implementation should have. It shows the allowed dependencies and the forbidden ones too:
The following is the list of allowed and forbidden dependencies: