This post was imported from my old blog and had 11 comments which are included as a screenshot at the end of this post.
Here is the sample code I demoed in my MIX11 session “Deep Dive MVVM”. Please download the Zip file, and then unblock it in Windows Explorer by right-clicking it, and then selecting Properties. If you see an “Unblock” button, please click it. You can then extract the content of the Zip file on your hard drive.
Last year’s session
To fully understand this session, an understanding of what MVVM is should be available. I recommend the following links:
- “Understanding the MVVM pattern” is the session I presented at MIX10.
- Sample code for “Understanding the MVVM pattern”.
- MVVM Light Toolkit “Get Started” page.
- MVVM Light Toolkit on Codeplex.
This year’s session
The video of Deep Dive MVVM is already available for download (awesome job, MIX team). Go to the MIX website to download it in various formats, or stream it.
Update: Getting the samples to run
In order to run the JsonDemo sample, you need to run the web application first because the Facebook service simulation is local. The easiest way is to right click on JsonDemo.SL4TestPage.html and select “View in Browser” from the context menu. This will start the development web server in Visual Studio. Then, you can run the WP7 application in the emulator.
For your convenience, I added the snippets of code that I was dragging/dropping from the Toolbox during the session. The file “snippets.txt” is included inside the ZIP file.
00 JsonDemo – Start
This is the start state, which will compile and run fine, but without the added functionality we built in during the session.
01 JsonDemo – After wiring up
This is the state of the application after the first demo, where all the objects are wired up and connected, and the message is sent from the MasterViewModel to the DetailsViewModel. We also added the IsOlderThanMeIndicatorVisibility property and connected it to the corresponding Rectangle in the DataTemplate (in the MasterView).
02 JsonDemo – Behaviors
This is the state after adding the “please wait” animation, the states and connecting the MasterViewModel’s IsBusy property to the GoToStateAction and ControlStoryboardAction instances through the DataTrigger. In Windows Phone 7, we added some code behind to replicate the functionality.
03 JsonDemo – WP7 DialogService
In this section we added a view service, the IDialogService, to the WP7 application and implemented it to display a custom message box. In SL4, the functionality is also available although no custom message box was made, so the fallback MessageBox is used instead.
This section introduces another view service, the INavigationService with one implementation in Silverlight 4 and one for Windows Phone 7.
05 JsonDemo – Unit test
In this last section, we add unit tests (with mock, well precisely with stubs!) to the Silverlight 4 and to the Windows Phone 7 applications. This is the final state of the demo.
I hope that this session was helpful, and that it will help you build awesome MVVM applications!