MVVM pattern
Model View ViewModel (MVVM) is an architectural pattern inspired by the Presentation Model design pattern designed by Martin Fowler (one of the greatest experts in the agile software development and object-oriented programming). It is the de facto standard for Silverlight and WPF. So why choose this pattern and not a different one? The answer is because it naturally adapts to the data binding mechanism of Silverlight, allowing us to explore all its capacities.
Let us begin by dissecting the pattern, where we can find the following layers:
Presentation: It defines the UI layout. The Code-Behind of every page only needs to contain code in charge of managing certain aspects of the UI.
ViewModel: It stores the state of the application and defines operations and notifications to the Presentation layer.
Data Model: It interacts with services and defines business rules.
How do these layers interact with each other? Let's take a look at the following figure:
Let's take a look at how...