Friday, October 1, 2010

MVVM overview (part 1 : What is MVVM)

So what is MVVM and what benefits are there in using it?

MVVM is a design pattern that is a variation on the MVC (Model/View/Controller) pattern.
MVC pattern seperates data model (Model) from the UI (View) and the application logic (Controller).
In MVVM there are also 3 layers: The Model (data model), the View (UI) and the ViewModel (Exposes the data from the Model
to the View), more on these layers later.

In modern applications this gives a significant advantage: The UI can be completely made by a designer, without him getting in touch with
the coding part of the application. (useful for Blend!)

Another advantage is testability, because the layers are seperated the ViewModel can easily be unit tested.

The databinding in WPF really makes this pattern shine, I'll show some examples later on.

So what are the disadvantages?

There are none! No seriously now, I don't really think there are major disadvantages in using MVVM pattern in WPF.
Maybe the fact that for some stuff (like for example showing a dialog box) .NET lacks in support, but there are MVVM frameworks that
can you help with these problems, and a good community searching and discussing solutions to these problems.


  1. you explain this very well, thanks

  2. why is everything but the actual articles in a diff language? why not just keep it all the same?

  3. Bart > Because I didn't find the button to change it... found it!

  4. Thanks for the info, will refer to this later on...

  5. It's M (Model) V (View) V M (ViewModel) ;)