Model-View-ViewModel [MVVM] is a design pattern for developing the UI Applications. It is a variation of MVC and MVP. MVP[Model-View-Presenter] which has been using for years to develop UI platforms.
Bit about MVP
View is what you see on the screen.Model displays the data and Presenter hooks the two elements together.You can read more about this pattern in August 2006 Design Patterns column.
What is MVVM?
ViewModel Contains the properties which exposes the data contained in model objects. View and ViewModel are associated with data bindings.Neither ViewModel nor View performs the modifications to the model data.
View View Classes have no idea of Model classes. When user clicks a button on the view, a command on the ViewModel performs the action. View consists of the visual elements and they are declared in XAML[WPF applications].
DataModel is responsible for exposing the data for that is consumed by WPF applications where as ViewModel is responsible for exposing the data for views and behaviors for the views.
Why MVVM for WPF?
The Data binding infrastructure of MVVM makes it famous for developing the WPF applications. Data templates is the other feature to make this pattern more usable. Data templates applies the views to the objects in the ViewModel. Data templates are declared in the XAML and Resource System locates the templates and apply them at run time.
ViewModel classes are easy to unit test as most of the interaction logic in ViewModel classes. ViewModel has no specific dependencies on visual elements. Developers can create a smooth designer\developer workflow.
More about this pattern can be found at http://msdn.microsoft.com/en-us/magazine/dd419663.aspx.
|Share this post :|