Model View ViewModel

This product was added to computer science because of the content, defects on the quality assurance side of the editor. This is done to bring the quality of the articles from the computer science subject area to an acceptable level. Help us to eliminate the substantive shortcomings of this article and take part you in the discussion! ( )

Model View ViewModel ( MVVM ) is a variant of the MVC separation of markup and logic of the UI. It aims at modern UI platforms such as WPF, Silverlight, and HTML5. MVVM provides for a separation of roles of UI designers and developers, making application layers can be developed by different working groups. Designers can set the focus on user experience, and developers write the UI and business logic.


The MVVM published by Microsoft MVP John Gossman 2005. It is a specialization of the Presentation Model of Martin Fowler and is with this identical insofar as both state and behavior patterns of the view in a separate UI Model ( Presentation or ViewModel ) move. However, the Presentation Model allows you to create a view independent of the UI platform, whereas the MVVM originally aimed at using WPF UIs. There is, however, now also used in other areas, similar to MVC.


The MVVM uses the functional separation of the MVC and data binding to achieve a loose coupling. It includes three components, the Model and View are similar to those of the classic MVC:

  • Model data access layer for the content that will be displayed to the user and manipulated by him. There notified of data changes and performs a validation of user-supplied data. It contains all the business logic and for itself alone by unit tests verifiable.
  • View: All through the Graphical User Interface ( GUI) displayed items. It binds to properties of the ViewModel to represent content and manipulate and pass user input. Through data binding the View is easily replaceable and their code -behind low.
  • View model includes the UI logic (Model of View) and serves as a link between the view and the above model. On one hand, it exchanges information with the model, so calls methods or services on. On the other hand, it represents the view public properties and commands. These are bound by the view of controls to output content or the transmission of UI events. Overall CRUD is possible. The ViewModel may thereby have no knowledge of the view.


Regarding WPF and Silverlight MVVM means that the view from a purely declarative XAML markup is. It can be designed by UI designers about using Expression Blend, using only data bindings must be created for ViewModel, but no code -behind. The logic is implemented in a programming language such as C # or VB.NET. The dependencies between markup and code are minimized.

Pros and Cons

The amount of glue code and business logic in the code -behind of the view is reduced. This allows the UI designer views make pure, and implement developer regardless of the Models and ViewModels. Furthermore, if the correctness of the data binding is believed not (usually manual ) UI tests necessary. Instead satisfy code-based unit testing of the ViewModel. Last "inherits" MVVM MVC the easier interchangeability of view.

However MVVM represents an added expense dar. For applications with a simple UI, it is overkill. For larger applications, the design of a sufficiently general ViewModels in advance can be difficult. The debugging of declarative data binding is also more severe than in imperative programming. Also, run a poorly managed data binding to a significant memory footprint of the application.