views:

6344

answers:

10

I understand the basics of the Model-View-ViewModel pattern or as Dan Crevier calls it the DataModel-View-ViewModel pattern and I understand that it is a good approach to design WPF based applications. But there are still some open question. For example: Where do I put my business logic where my validation logic? How do I decouple the Database (in a way that the underlying storage solution can easily be exchanged) from the Model but still be able to do complex data mining? How do I design the ViewModel that it can observe state changes in the Model?

Do you know of any applications that use this pattern that I could study for evaluate different approaches? Preferably ones where the source code is available?

Or maybe you even know of articles, books, blogs, websites that go a bit more into detail?

+30  A: 

I am still exploring these patterns myself, but I would point you to the Stock Trader reference implementation inside of Prism (aka the Composite Application Guidance for WPF).

Prism calls the pattern 'Presentation Model'. You can find more info about Prism from Glenn Block's blog and Brian Noyes' blog. Here also, is the MSDN link to the Presentation Model in Prism.

I know that Blend also uses the M-V-VM pattern extensively. It is too bad that the Blend source code isn't open to all.

Finally, don't miss this blog post which points to a video done by Jason Dolinger on M-V-VM. It's excellent and highly recommended. My blog also has sample code to follow along the video with.

Update

I just wanted to add to this post all the links/posts that I have discovered on this topic:

  1. Dan Crevier's series on Data Model-View-View Model
  2. John Gossman's series on Model-View-View Model: 1, 2, 3, 4, 5, 6
  3. Julian Dominguez (from the Prism team) has three posts of interest: 1, 2, 3
    In the third post, he has a little sample application that shows off Presentation Model with DataTemplate(s).

Update #2

Josh Smith just published an excellent article on M-V-VM for MSDN Magazine. It comes with some sample code too!

cplotts
The presentation Model of PRISM is in reality a passive view (the presenter knows an interface that represents the view) and a presentation model of Martin Fowler (All the data of the view are stored inside the presenter, and synchronized with the view). MVVM is only the presentation model of MF.
Nicolas Dorier
Jason Dollinger's video is excellent. Highly recommended.
Gus Paul
The Jason Dollinger video is the best place to get started, it's excellent.
Cole Shelton
+2  A: 

See this very informative post from Karl - http://karlshifflett.wordpress.com/2008/11/08/learning-wpf-m-v-vm/

Jobi Joy
A: 

Another very interesting read: A discussion from the WPF disciples group: Thought: MVVM eliminates 99% of the need for ValueConverters

bitbonk
+13  A: 

Jason Dolinger has a great (long) screencast of MVVM

http://blog.lab49.com/archives/2650

viggity
That screencast is a great intro to MVVM
Wilka
+3  A: 

Josh Smith has put together one of the best implementations of M-V-VM in his Crack.NET project. All of Josh's projects are good, but this one is outstanding.

Pete OHanlon
A: 

I just blogged about this in Presentation Model Without INotifyPropertyChanged. This is a technique that you can use to implement the M/V/VM pattern without writing any bookkeeping code. You don't need to implement INotifyPropertyChanged. You can bind directly to plain-old .NET code in your View Model, and it will update when your Data Model changes.

Michael L Perry
+2  A: 

Hi,

I'm researching MVVM myself right now, so I have a few additional references to offer. Jeremy Alles recently published a "Very Simple M-V-VM Demo Application", then there's Josh Smith's WPF apps with the Model-View-ViewModel design pattern in MSDN Magazine and Karl Shifflet's Channel 9 show about MVVM. And last but not least Jaime Rodriguez' just released his very nice M-V-VM training day sample application "Southridge Realty".

andyp
A: 
Przemek
A: 

Mark Smith has a great helper library for MVVM/WPF usage here

Gus Paul