New Pluralsight Course: Building Windows 8 MVVM XAML Apps

My new course went live today at Pluralsight.com: Building Windows 8 MVVM XAML Apps. It was a lot of fun making this course and I plan to do a lot more Pluralsight courses in the future. I wanted to give you a quick rundown of what the course contains beyond just what you see in the outline at the link above.

It is important to point out that 70% or more of the content of this course apply equally to WPF and Silverlight developers. There are some Windows 8 specifics in the first module and in the one on navigation. But otherwise the rest of the course applies just as much to any XAML technology.

Windows 8 MVVM Fundamentals

In this module I cover the basic concepts of what it means to be a Windows 8 / Windows Store / Modern UI / WinRT app – the app style formerly known as “Metro”. I cover some of the nuances of what differentiates those terms and what the requirements are to be one, as well as how it affects you in designing the app. Then I talk about the design goals of MVVM, some background on how it relates to MVC and MVP, and also how MVVM is a shared pattern across other XAML technologies.

Getting Started with MVVM

This module is partly about what you need to know to get started with MVVM, as well as some core concepts, or a quickstart on MVVM at the end of the module. I cover fundamentals of Data Binding, Property and Collection Change events, and Commands as platform level features that you need to understand and leverage to do MVVM in the first place. Then I talk about the up front, 5 minute elevator pitch of what you need to know about MVVM in a single slide, and then demo a simple MVVM application showing how all those things come together.

Structuring an App with MVVM

This is one of the most important modules in the course. It is where I drill into the fundamental responsibilities of Views, ViewModels, and Models and how they relate to one another and how to get them wired up to one another. Then I dig into the communications between Views and ViewModels, talking about and demonstrating how and when to use PropertyChanged notificiations from the ViewModel or Model properties up to the View, Commands from the View down into the ViewModel, property setting from the View as a means of communication down into the ViewModel, and direct calls from the ViewModel up to the View when necessary through an interface abstraction.

MVVM Support – Behaviors and Repositories

This module covers two related concepts that become very important when trying to stick to the MVVM pattern: how to define and use Behaviors (both Attached and Blend-style behaviors) to add functionality into a view that the elements don’t directly support themselves, such as transforming a control event into a command invocation on the ViewModel. Then I talk about repositories, which are a pattern that you can use on the client side to decouple your view models from how data gets into and out of your UI layer. And of course I have good demos of how to create a use an Attached Behavior, a Blend-style behavior with WinRtBehaviors ( a great little community NuGet package to help us bridge the gap until the Blend team gets around to getting us a Blend SDK for WinRT), and a Respository that uses the new async/await keywords (the Task-Based Async Pattern).

Dynamic MVVM Structuring

In this module I cover how to get Views and ViewModels dynamically associated and hooked up through DataTemplates in a container control such as a ContentControl or FlipView, using a two level ViewModel hierarchy where a parent view model exposes a collection of child view models, which get rendered based on a DataTemplate associated with them. In WinRT this requires a DataTemplateSelector, which I also show how to define and use in the demo. Then I talk about the concept of ViewModelLocators and show two different ways to get them defined and use them – one through an object you can put in Application Resources that returns view models through bound properties similar to how MVVM Light does it, and one that uses an attached property and convention over configuration to automatically select a view model.

Windows Store Application Navigation with MVVM

In this module I get into the navigation mechanisms of WinRT and also how they tie in with the application lifecycle of suspend-terminate-resume. I cover the build in project templates and common infrastructure classes that get injected into those project by default, and how the navigation and state management works using those templates with no MVVM in the equation. Then I show how you can delegate responsibility to the ViewModel for persisting the state it is managing and giving it control of when and where to navigate to.

MVVM Maintainability

One of the benefits of using MVVM is better testability of your UI logic code. It is also important to be able to leverage the full capabilities of both the Visual Studio and Expression Blend designers for better productivity in laying out and hooking up the elements in your views. So in this module I show how to use the MVVM pattern, but still have access to the exposed properties of your view model and model objects for design time hookup without having to edit the XAML, as well as being able to show custom design time data in the designer while you work on laying out and sizing the elements in your UI. Then I get into the concepts of unit testing and mocking and demonstrate some common approaches to testing your view model and mocking out its dependencies for unit tests.

MVVM Toolkits

In the last module, I give you a quick intro to some of the most popular MVVM toolkits / frameworks out there, specifically MVVM Light, Caliburn Micro, and the Microsoft patterns and practices guidance/toolkits Prism and a follow on they are working on now for WinRT (and I am part of the team for like I was on Prism 1 and Prism 4).

So if you don’t already have a Pluralsight subscription, I recommend you get one and check it out!

I’m looking forward to any feedback, so if you have some, please make sure to share it.