The paste couple week I’ve had two blog post that I just can’t finish. One is fully detailing my light weight 3d framework, and the second one is a post that compiles a list of MVVM resources and learning’s. A colleague of mine at Schematic, Herberth Madrigal, put together a list of what he’s learned and shared it with the our Microsoft group. Herberth’s notes are really well done, and he since he doesn’t have a blog, and I’ve been trying to finish a MVVM post, I asked and he graciously allowed me to post his notes here. Thanks Herberth.![]()
Herberth’s notes:
I’ve tried to get a better knowledge of the MVVM (UI design) pattern during the past days. Here are some notes that I’ve found and I want to share with you.
1. MVVM, a WPF UI Design Pattern: Channel 9 has this video where they explain things like: why do we use MVVM? and what is MVVM? An a very simple explanation of How to implement it.
http://channel9.msdn.com/shows/Continuum/MVVM/
2. AFAIK, this pattern is easier to implement in WPF than in SL2. This is because WPF has more available tools such as triggers or routed commands. For this reason, you might see many implementations of libraries and helpers in order to implement this model in SL So, there are some libraries and ideas of how to work around this issue in Silverlight.
ViewModel Pattern in Silverlight using Behaviors: This guy uses a ‘behaviors‘ in order to keep communicate the XAML and the ViewModel.
http://www.nikhilk.net/Silverlight-ViewModel-Pattern.aspx. This guy has an article with a more detailed explanation about behaviors just in case you need it.
ICommand for Silverlight with Attached Behaviors: This buddy uses ICommand (an interface added into SL2 release). If you haven’t understood this pattern yet, then the sample in this article is must see.
Something that it’s kinda good about this implementation is that this guy uses two files from the library: Microsoft patterns & practices, Composite Application Guidance for Windows Presentation Foundation and Silverlight. This library is hosted in codeplex at http://www.codeplex.com/CompositeWPF/. BTW This is the most simple sample that I’ve seen of how to implement MVVM, look at the code behind of the Page.xml, and you’ll see the magic of this pattern.
MVVM pattern in Silverlight using SLEextensions: This guy uses a library called SLExtensions. This library has many others services other than the p&p (patterns and practices).
http://blog.developers.ba/post/2009/02/15/MVVM-pattern-in-Silverlight-using-SLEextensions.aspx
You can see http://www.codeplex.com/SLExtensions for more info about SLExtensions.
3. Code Snippets: This pattern uses extensively bindings and dependency properties. It may be useful to be able to write more quickly binding code or dependency property code. So, one guy has created lot code snippets for dependency properties, routed command and routed events for Vb and C#. You can get them from http://drwpf.com/blog/Home/tabid/36/EntryId/22/Default.aspx BTW, this snippets are for WPF, however it’s kinda easy to modify and make them SL compatible where possible.



March 11th, 2009 at 10:34 pm
In this month the MSDN Magazine Shawn Wildermuth has written about ‘Model-View-ViewModel
In Silverlight 2 Apps’ in http://msdn.microsoft.com/en-us/magazine/dd458800.aspx
He didn’t use command nor behaviors. He simply wrote the event handler in the code-behind’s view instead of
implementing behaviors or other techniques.
March 12th, 2009 at 6:04 am
Cory, I suspect he was showing how to do this without any 3rd party libraries, it’s not preferred, the goal is to not have any ‘code behind’, and it is possible.I highly recommendSilverlightFX mentioned above, or Caliburn (on CodePlex)Once you start using these, you’ll never need to ‘code behind’ (well, I should say 99% of the time - lol)
March 12th, 2009 at 6:06 am
As far as http://blogs.southworks.net/jdominguez/2008/08/icommand-for-silverlight-with-attached-behaviors/#commentsThanks - that is fantastic!
March 12th, 2009 at 7:26 am
[...] MVVM notes and references (Corey Schuman) [...]