share
Stack OverflowWhat applications could I study to understand (Data)Model-View-ViewModel?
[+52] [11] bitbonk
[2008-11-08 19:47:13]
[ .net wpf design-patterns mvvm ]
[ http://stackoverflow.com/questions/275098/what-applications-could-i-study-to-understand-datamodel-view-viewmodel ] [DELETED]

I understand the basics of the Model-View-ViewModel pattern or as Dan Crevier calls it the DataModel-View-ViewModel [1] 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?

[+36] [2008-11-08 23:16:10] cplotts [ACCEPTED]

I am still exploring these patterns myself, but I would point you to the Stock Trader reference implementation inside of Prism [1] (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 [2] and Brian Noyes' blog [3]. Here also, is the MSDN link to the Presentation Model in Prism [4].

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 [5] which points to a video done by Jason Dolinger on M-V-VM. It's excellent and highly recommended. My blog [6] 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 [7] on Data Model-View-View Model
  2. John Gossman's series on Model-View-View Model: 1 [8], 2 [9], 3 [10], 4 [11], 5 [12], 6 [13]
  3. Julian Dominguez (from the Prism team) has three posts of interest: 1 [14], 2 [15], 3 [16]
    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 [17] on M-V-VM for MSDN Magazine. It comes with some sample code too!

[1] http://www.codeplex.com/CompositeWPF
[2] http://blogs.msdn.com/gblock/archive/2008/07/03/composite-application-guidance-is-live.aspx
[3] http://www.softinsight.com/bnoyes/2008/07/03/CompositeApplicationGuidanceForWPFAkaPrismShips.aspx
[4] http://msdn.microsoft.com/en-us/library/cc707885.aspx
[5] http://blog.lab49.com/archives/2650
[6] http://www.cplotts.com/2009/06/16/code-to-work-along-with-while-watching-jason-dolingers-m-v-vm-video/
[7] http://blogs.msdn.com/dancre/archive/2006/10/11/datamodel-view-viewmodel-pattern-series.aspx
[8] http://blogs.msdn.com/johngossman/archive/2005/10/08/478683.aspx
[9] http://blogs.msdn.com/johngossman/archive/2005/10/09/478894.aspx
[10] http://blogs.msdn.com/johngossman/archive/2006/02/26/539598.aspx
[11] http://blogs.msdn.com/johngossman/archive/2006/02/27/540304.aspx
[12] http://blogs.msdn.com/johngossman/archive/2006/03/04/543695.aspx
[13] http://blogs.msdn.com/johngossman/archive/2006/04/13/576163.aspx
[14] http://blogs.southworks.net/jdominguez/2008/04/using-the-presentation-model-in-wpf/
[15] http://blogs.southworks.net/jdominguez/2008/05/first-approach-to-presentation-model-with-datatemplates/
[16] http://blogs.southworks.net/jdominguez/2008/09/presentation-model-with-datatemplates-in-compositewpf-prism-sample/
[17] http://msdn.microsoft.com/en-us/magazine/dd419663.aspx

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
(3) 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
1
[+16] [2008-12-05 20:50:18] viggity

Jason Dolinger has a great (long) screencast of MVVM

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


(4) That screencast is a great intro to MVVM - Wilka
2
[+4] [2008-12-05 20:55:25] Pete OHanlon

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

[1] http://joshsmithonwpf.wordpress.com/cracknet/

3
[+3] [2009-02-11 22:22:43] andyp

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

[1] http://www.japf.fr
[2] http://www.japf.fr/?p=137
[3] http://joshsmithonwpf.wordpress.com
[4] http://msdn.microsoft.com/en-us/magazine/dd419663.aspx
[5] http://karlshifflett.wordpress.com
[6] http://channel9.msdn.com/shows/Continuum/MVVM/
[7] http://blogs.msdn.com/jaimer/default.aspx
[8] http://blogs.msdn.com/jaimer/archive/2009/02/10/m-v-vm-training-day-sample-application-and-decks.aspx

4
[+2] [2008-11-09 06:02:31] Jobi Joy

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


5
[+2] [2008-11-09 08:24:37] bitbonk

Here are some more resources by Josh Smith [1]:

[1] http://joshsmithonwpf.wordpress.com/
[2] http://www.codeproject.com/KB/WPF/TreeViewWithViewModel.aspx
[3] http://www.codeproject.com/KB/WPF/VMCommanding.aspx
[4] http://www.codeproject.com/KB/WPF/MVCtoUnitTestinWPF.aspx
[5] http://joshsmithonwpf.wordpress.com/2008/11/14/using-a-viewmodel-to-provide-meaningful-validation-error-messages/

6
[0] [2008-12-04 09:35:13] bitbonk

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

[1] http://groups.google.com/group/wpf-disciples/browse_thread/thread/3fe270cd107f184f

7
[0] [2008-12-30 13:18:11] Michael L Perry

I just blogged about this in Presentation Model Without INotifyPropertyChanged [1]. 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.

[1] http://www.adventuresinsoftware.com/blog/?p=284

8
[0] [2009-02-27 09:43:10] Przemek

I would like to share with you some recent web activities that may shed some new light on the question:

[1] http://msdn.microsoft.com/en-us/magazine/dd458800.aspx
[2] http://pixel8.infragistics.com/shows/mvvm-sl.aspx#Episode:11927

9
[0] [2009-04-30 15:24:15] Gus Paul

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

[1] http://www.julmar.com/blog/mark/PermaLink,guid,8b3e4279-70a5-431e-8fa3-4c1e047df311.aspx

10
[0] [2011-02-20 19:07:55] jbe

You might be interested in the WPF Application Framework (WAF) [1] project. It provides extensive sample applications which are using the MVVM pattern and some documentation about the Pattern itself.

[1] http://waf.codeplex.com

11