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?
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.
I just wanted to add to this post all the links/posts that I have discovered on this topic:
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/CompositeWPFJosh 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/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.frSee this very informative post from Karl - http://karlshifflett.wordpress.com/2008/11/08/learning-wpf-m-v-vm/
Here are some more resources by Josh Smith [1]:
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/3fe270cd107f184fI 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=284I would like to share with you some recent web activities that may shed some new light on the question:
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.aspxYou 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