MVVM Pattern and Silverlight
I have been trying to understand the Model-View-ViewModel pattern for a while and to be honest, getting a good grip on the idea was eluding me. I read many articles; some were too general to be helpful, some were written specifically for WPF (which does not map well to Silverlight because of Silverlight’s lack of commands and triggers), or were shown in applications that were just too complex to really see what was happening.
Then I read Shawn Wildermuth’s article in MSDN Magazine. Shawn showed a fairly simple MVVM example using Silverlight and C#. Thanks to the efforts of Lisa Feigenbaum, Shawn’s code was provided not only in C#, but also in VB.NET in the MSDN Code Gallery.
I decided that I would create my own simple Silverlight client using the MVVM ideas presented by Shawn. I just posted a new tutorial that shows how this application is designed. In this tutorial, I look at a very simple ViewModel that deals with displaying all products from the AdventureWorks database. It shows two versions of the data contract, one using .NET RIA Services and a second using ADO.NET Data Services. In this example, the view is defined as a Silverlight client.