Recommended before going through examples:
- Install correct visual studio version
- Get a copy of the data binding cheat sheet
Optional:
- Download the MVVM Light code snippets from http://mvvmlight.codeplex.com/sourcecontrol/latest and install them in your visual studio environment.
- You will likely want to either use the above snippets, or create your own.
Important: None of these examples currently take into account the app life-cycle of a Windows Store application. So be aware if you are working on a real app that the life-cycle will need to be handled correctly. See the msdn article Part 2: Manage app lifecycle and state (Windows Store apps using C#/VB and XAML) for details.
Examples (checkout specific revision to run):
- Example 1 - “One Time” binding with separate design and runtime data.
- Example 2 - Binding that responds to value changes - raising notify property changed
- Example 3 - Introducing Commands and two-way binding
- Example 4 - Introducing Behaviors and Dependency Properties
- Example 5 - Introducing testing, SimpleIoC and domain model interaction
- Example 6 - Introducing custom views (user controls) and content presenter and data templates - Pending “Metro XAML” does not deal with this in the same was that “WPF XAML” does. Possibly need to implement a custom data template selector.
- Example 7 - Introducing Messaging (pending)
- Example 8 - Introducing Binding Converters / markup extensions. (pending)
- Example 9 - Binding to Collections (pending)
TODO:
- MvvmLightToolkit “EventToCommand” does not appear to be available for Windows Store apps. For WPF apps, it enables triggering a specific command when a particular event occurs.MvvmLightToolkit: EventToCommand not available for Windows Store Apps? Possible replacement is the behavior SDK, but I keep getting errors, see: , another possibility is http://winrttriggers.codeplex.com/. Or it would probably not be too difficult to implement a generic enough custom behavior to take its place? Example 4 pretty much shows how to do it in a very specific scenario - a more generic helper would need to add a dommand parameter dependency property as well.