In the tutorial titled “Introduction to Silverlight 4 and WCF RIA Services’”, I created an application that keeps track of golf course information and scores and also computes a golfer’s handicap. This application used Silverlight 4 and WCF RIA Services with the application logic located in the Silverlight code-behind. In the tutorial titled “Silverlight 4 and the Model-View-ViewModel (MVVM) Pattern’”, I introduced MVVM concepts with a very simple example. In this tutorial, I revisit the golf application by refactoring the code-behind into two view models.
I must admit that I have struggled for some time really understanding the MVVM pattern. I read a lot of articles and blogs, and I learned a lot, but I never really “groked” the concept to my satisfaction. I read John Papa’s blog on Silverlight 4 Commanding. I worked with his code, converting it to VB, and then started to experiment. The result of the experiment was the Silverlight 4 and the Model-View-ViewModel (MVVM) Pattern tutorial. Then I started working with the Golf Handicap Application, this time building a view model for the Course management child window, and another view model for the score management child window.
Well … GROK! I got it it. It was one of those nice experiences when a small intellectual step brings great satisfaction.
I hope that this new tutorial might help you “see the light” in the MVVM and Silverlight world. I should point out that there is no single approach to implementing the MVVM pattern so you may find other approaches better for your needs.