Just wanted to let everyone know about a fantastic video on MVVM. The presenter, Jason Dolinger, starts off showing you how to develop a simple "Stock Quote" program the wrong way (i.e. the Winforms way) and then refactors it to use the WVVM pattern. It is quite long (1:30) but well paced.
The video is available at: http://blog.lab49.com/archives/2650
The source code is available at http://blog.lab49.com/archives/2689
Yes it's a great video.
One of the three anyone interested in MVVM should watch.
It's 2 years old though, as is the top post.
…we each have more potential than we might ever presume to guess. (Blog: http://dsmyth.blogspot.com/)
I think you're best watching something simple first.
And yes, it's silverlight. Still watch it even if you don't intend doing any silverlight.
Which you should watch last. It'll blow your mind.
All of these have been around for a while.
Resource wise there's also Josh's book and Apress have just recently published a paper book.
Anyone new to working with MVVM will also eventually want to attach commands via a style. Marlon Grech's ACB is the way I like to do this.
I think digesting that lot'll keep you busy for quite a while!
Any time mate.
The way I think about things is probably kind of obvious but might help if you're starting out. Or if someone else's reading this.
The view is the thing the user sees and allows him to interact with stuff. It should be concerned with presentation and you want to minimise code behind but a load of xaml is fine.
The Viewmodel adapts the data and actions to the view. So all your doing-stuff code is used by it but is probably in separate classes. You have one instance of a viewmodel per thing presented. Say you have a screeen shows some guff about an order and a list of order lines. You want an order viewmodel which exposes a collection of ordel line view model(s). How you connect up commands to those order lines is one of the tricky bits - I expose a command out each of the order line viewmodels and use ACB to wire that up. It's a very different way of working because there's no button click event code like most of us from a vb3-vb6 background expect.
The model connects up your actual data.
If it all sounds a bit tricky, it gets easier and you'll find that it's WAY easier than sticking with your old click events style once you get into serious coding.
Beautiful! Thank you for posting =)
May the Force be with you young Jedi...
Please Help your Helper(s) =)
If you find someone's post helpful please click the green "up arrow" to the left and vote!
Did someone's post Answer your question? Mark it as the Answer!
It's Really Appreciated =)
- Edited by DarthBerg82 Thursday, July 19, 2012 6:03 PM