Also, if there is no logic in the View itself, it eliminates the risk of “stale” or unused code creeping into the View, which often happens in Windows Forms.
Now that we have the View and the Model defined, we need a way to hook the two things together.
Let’s review our goal of maintaining a full separation of presentation and logic, this time just in terms of the View.
When we create our user interface, we want to define what the user will see (presentation) without worrying about how the program works (logic).
In MVVM, the View Model sits between the View and the Model, and basically acts similar to an Adapter – it translates the properties and methods of the Model to a form that can be directly used via Data Binding.
The View Model also provides us a place to manage application state and logic.
This may be customer records in a database, or product information on a website, or anything else.
As I mentioned, MVVM can make developing applications in WPF efficient, quick, and highly maintainable.
In Model-View-View Model, our goal is to keep the model unaware of the specific application or technology that’s using it. As I mentioned in part 3, WPF changes how the View is normally defined.
Instead of developing the user interface via code, we use XAML to create an XML-based, declarative description of the interface.
We’ve seen some of the advantages in terms of control creation – unlike Windows Forms, we can completely change the way a control looks merely by creating a new template, using XAML in a completely declarative form. In order to understand MVVM, I will start off by defining our distinct concerns, the individual “parts” of our application.
I already defined our arguably most important concern: the Model.