Jason Dolinger on Model-View-ViewModel
A while back, Jason Dolinger, a consultant here at Lab49, gave us a presentation on design in WPF with the Model-View-ViewModel pattern and the Unity dependency injection framework.
Jason started with an application that one would write in a “traditional” way, with button clicks handled by event-handlers in the code-behind that then updated other parts of the UI. Using WPF data-binding, Commands, and Unity, he transformed it, piece by piece, in a much more manageable, encapsulated, readable, and testable M-V-VM design. It was awesome.
It was so awesome, in fact, that after the presentation Jason recorded the demo for all to see here.
Check it out. It’s the most practically instructive explanation of WPF design I’ve seen.
UPDATE: I thought I should mention that while Jason’s presentation is geared towards WPF, the patterns he describes are very applicable for Silverlight as well. There are a few things to take note of, though:
1) Jason creates ViewModels that are DependencyObjects. For some (apparently undocumented) reason, DataContexts in Silverlight cannot be DependencyObject descendants. That means that you need to implement ViewModels as INotifyPropertyChanged (an option also available for WPF that Jason mentions in his video). This doesn’t fundamentally affect the pattern, but should be noted.
2) Unity, which Jason uses for dependency injection, is available for Silverlight right now as part of pre-release Composite WPF & Silverlight (Prism) v2. You can download it here. (I haven’t been able to find Unity for Silverlight as a separate download.)
3) Silverlight does not support bindings for Commands out of the box. It does, however, expose the ICommand interface. With just a little bit more work using an “Attached Behavior” approach, we can get the kind of Commanding that Jason uses in Silverlight as well. Check out the description here.


November 6th, 2008 at 11:19 pm
Fantastic. This is the best intro to MVVM I have seen. Keep things like this coming.
November 6th, 2008 at 11:20 pm
Can we download the code somewhere?
November 7th, 2008 at 4:57 am
I have to say this video was fabulous! I agree with Shawn by saying it is the best intro to MVVM and IoC I’ve ever seen.
Thank you!
-Jer
November 7th, 2008 at 7:59 am
Excellent presentation.
November 9th, 2008 at 9:59 am
Brilliant!
Jason loves to hit those keys. Ouch!
November 9th, 2008 at 2:35 pm
Very nice presentation ! Thank you very much for your work.
November 10th, 2008 at 2:45 am
[...] Jason Dolingers cast on Model-View-ViewModel [...]
November 10th, 2008 at 5:42 am
Wow! I’m left speechless! Absolutely brilliant presentation. I’ve implemented a WPF project in the M-V-P pattern, and after watching this, have converted it into M-V-VM
Thanks a great lot for uploading this video.
November 10th, 2008 at 8:57 pm
Thanks. What a great presentation!
November 11th, 2008 at 4:21 am
Thanks. Great presentation!
November 12th, 2008 at 8:38 am
Superb! Thanks very much.
November 15th, 2008 at 5:03 pm
Wow! This was really enlighting. This simple and easy to understand video answered all my current questions I had on designing a wpf based application. What a great relief to know it’s all not that hard to build a wpf application that is modular, unittestable and designable. Can I have more like this? Please?
November 21st, 2008 at 8:49 am
I agree, this is an excellent presentation. There is so much here I am also wondering if we can get the final code somewhere.
November 21st, 2008 at 10:31 am
Very well done–thank you.
November 28th, 2008 at 11:30 pm
Great presentation! Is the code available for download?
November 30th, 2008 at 3:02 pm
[...] comparto el link que me hizo llegar al video, donde se indica el caso de cómo aplicar el patrón para el caso de [...]
December 3rd, 2008 at 3:58 pm
I agree with all this Presentation rocks, thank you! Is the code available for download?
December 3rd, 2008 at 4:17 pm
I’ve tried to recreate the program and you can download it from here:
http://reyntjes.blogspot.com/2008/12/my-version-of-jason-dollingers.html
December 3rd, 2008 at 7:15 pm
[...] time back, I posted Jason’s presentation on Model-View-ViewModel and dependency injection with WPF and Unity (if you haven’t checked [...]
December 5th, 2008 at 12:13 pm
This is such a great resource with the best overview of M-V-VM that I’ve seen yet in nearly 4 months of searching/struggling with the WPF learning mountain. Thanks again for doing such a great job!
December 8th, 2008 at 5:35 pm
Good Demonstration. it helped me a lot in understanding ViewModel concept.
December 11th, 2008 at 2:55 pm
Just to mention that Unity1.2 has just been released with support for Silverlight2 too – check it out – http://www.codeplex.com/unity
December 15th, 2008 at 6:12 am
awesome! but where’s the code?
December 18th, 2008 at 11:44 pm
This is the holy grail of MVVM instruction because he gives context by starting the old way and refactoring to the proper way which allows us to relate the new constructions to the old constructs. He also covers several different ways of doing it, implementing them all.
MVP overview
Routed Events
ICommand routing through binding
UnitTesting
UnitTest Autogeneration
Datasource Mocking
Unity Dependency Injection…
Good god thank you!
December 20th, 2008 at 2:48 pm
It seems the video is missing. Can someone please point out where to get it?
thanks.
December 20th, 2008 at 3:11 pm
kowadis:
I have no trouble getting to the video from the link (at the word “here” in the third paragraph). The URL is http://www.lab49.com/files/videos/Jason%20Dolinger%20MVVM.wmv .