Bookmark and Share Share...    Subscribe to this feed Feed   About me...


Model-View-ViewModel Pattern

This article is not yet finished...

Introduction

In conventional user interface programming techniques (as we know it from WinForms) we usually add event handlers to controls and implement the logic of a view in the code-behind. It is the most simple and fastest way to get a functional user interface. But this approach has some disadvantages:

  • Presentation and logic are tightly coupled
  • Replacing a control on the view often requires code changes
  • You cannot have more than one view sharing the same logic
  • To test the user interface logic you need to do complex UI testing.

Introducing the Model-View-ViewModel pattern

WPF brings up a very flexible and powerful databinding framework and this favors a new pattern how to bind presentation and logic together.

The idea of the MVVM pattern is the following:

  • A model that contains the data
  • A passive view-model that collects and prepares the data so that is can easy be consumed by the view.
  • And a view that is defined in XAML and should not have any logic in the code-behind. It binds to the view-model by only using data binding.

Model-View-ViewModel Example

Model

ViewModel

View




 Comments on this article

Show all comments
Divyadhar Ojha
Commented on 14.May 2010
It's Not Enough For Code .
James
Commented on 26.May 2010
Explainations are not good enough to understand more
Vinay
Commented on 1.June 2010
I could very well understand what you mentioned in this article till now. Eagerly waiting for you to finish it to understand it further..
Vaishno
Commented on 11.June 2010
hi can you please provide some more details including sample that implements that .
Tauqir
Commented on 15.June 2010
Please can you add some update on the topic, it will be really thankfull.
D
Commented on 29.June 2010
your article is perfect to understand and is needed more better. Also Lol'd is big douche.
Poorna
Commented on 1.July 2010
Guys...Please dont complain about this postings, at least he is trying to contribute to dev community.
Tom
Commented on 8.July 2010
http://msdn.microsoft.com/en-us/magazine/dd419663.aspx
always_compl...
Commented on 21.July 2010
Why post it if it is not complete?? Thanks for your other articles though.
john
Commented on 27.July 2010
I don't know about you guys, but this link goes inside my bookmarks. This what I searched for some time. A quick review of different technologies and features like xaml, wpf, mvvm etc. It's kind of like a reminder of all technologies in one bucket. Good job!
theDude
Commented on 2.August 2010
That is a seriously gay photo of your boyfriend on the header.
theDude
Commented on 2.August 2010
Actually the gay tard in the header probably has a gerbal up his butt. Which explains the gay grin on his face.
theDude
Commented on 2.August 2010
So back to the gay photo on the header... Did his mom dress him or did he just buy whatever was on the first display mannequin at GAP? I love irony.
theDude
Commented on 2.August 2010
Ok, so I got it now. The sun rising over the mountian in the header is a metaphore for the gay dude coming out the closet to the right.
theDude
Commented on 2.August 2010
To the gay dude in the header: referee shirts have the stripes running vertically not horizontally. get it together..
theDude
Commented on 2.August 2010
So I bet if we could scroll the header down you'd see the gay dude's pants down and his boyfriend going to town on his cock. mmmm, gay
corvette
Commented on 5.August 2010
Chris,
Please can you delete theDude's pathetic and immature comments.
PS Please can you answer how MVVM differs from MVC. I can probably find the info elsewhere I know (eg http://stackoverflow.com/questions/667781/what-is-the-difference-between-mvc-and-mvvm), but why would I do that when your explanations are usually so good ?
Cheers
PS If I were you I would only allow comments from registered users. Shame but how else can you deal with Sad people.
Darshit Dave
Commented on 11.August 2010
Hi Chris,
I started to use this site a day before and enjoying learning WPF very qucikly.
I had heard about VVMM MVVM pattern and really eager to learn it.

Can you please complete the architecture when ever you get time? I know its hard to find out time from routine work, but we do expect your valuable guidance.

Thanks.
Jimsom
Commented on 13.August 2010
look forward completion
venkadesh
Commented on 17.August 2010
Let me send the samples
john
Commented on 18.August 2010
@theDude are you gay dude ?
theDude
Commented on 19.August 2010
@john, how long have you and the fag in the header been dating? Which of your mom's dress you two?
theDude
Commented on 21.August 2010
Sounds like this article is really a metaphore for the Ass-Poke-PokeAss pattern. According to the diagram when you get to the Ass, you recieve double penetration.
theDude
Commented on 25.August 2010
Speaking of double penetration, hows the faggot in the header holding up these days?
shankar
Commented on 31.August 2010
wats the use of mvvm?

Name
E-Mail (optional)
Comment
About Christian Moser