WPF MVVM In Depth

This course provides end-to-end coverage of what you need to know to effectively apply the MVVM pattern to WPF applications.
Course info
Rating
(743)
Level
Intermediate
Updated
Jun 13, 2015
Duration
2h 54m
Table of contents
MVVM Pattern Fundamentals
First Taste of MVVM
Hooking up Views and ViewModels in MVVM
View/ViewModel Communication in WPF
Applied MVVM Part 1 - Hierarchies and Navigation
Applied MVVM Part 2 - Validation and Dependency Injection
Description
Course info
Rating
(743)
Level
Intermediate
Updated
Jun 13, 2015
Duration
2h 54m
Description

This course introduces WPF developers to the MVVM design pattern and teaches them how to apply it to a wide range of compositional scenarios for building out WPF client applications. The course covers the motivations for using the pattern, the fundamental concepts of the pattern, and then demonstrates how to apply it for a number of common scenarios. It covers various different ways of defining Views, ViewModels, and attaching to one another. It shows how to use common data bound controls in the context of MVVM and how to hook them to ViewModels and Models, both statically and dynamically. It shows how to communicate between View and ViewModel with data binding, commands, and behaviors. Finally, it shows how to use View and ViewModel hierarchies and set up navigation between Views within a container.

About the author
About the author

Brian Noyes is CTO and Architect at Solliance, an expert technology solutions development company. Brian is a Microsoft Regional Director and MVP, and specializes in rich client technologies including XAML and HTML 5, as well as building the services that back them with WCF and ASP.NET Web API.

More from the author
WPF Productivity Playbook
Intermediate
2h 57m
Aug 22, 2016
More courses by Brian Noyes
Section Introduction Transcripts
Section Introduction Transcripts

MVVM Pattern Fundamentals
Hi, this is Brian Noyes, and welcome to this course WPF MVVM In Depth. Every good WPF developer wants to write great applications that delight their users, and you may be able to achieve that on a first release without putting a lot of consideration into the structure of your application code and what code belongs where. But if you want to keep adding features and fixing bugs and getting releases out over time, without your delivery times constantly increasing due to code complexity, you need to have good clean structure to your code. The Model-View-ViewModel, or MVVM pattern, is all about guiding you in how to organize and structure your code to write maintainable, testable, and extensible applications. This first module is going to cover the high-level concepts of MVVM. Make sure you understand what it does for you, why you'd want to use it, where it comes from, and some of the high-level concepts around the structural parts of MVVM. So let's dive right in.

First Taste of MVVM
Welcome back to the second module of WPF/MVVM In Depth. In this module I want to give you a quick exposure, or taste, of how using MVVM changes some coding patterns for a simple input screen in a WPF application that you may already be used to. I'll do this by stepping through three variants of the same simple application and demos. The first will have no MVVM, nor data binding in it. The second will at least leverage data binding, but have no MVVM, and the third will evolve into showing the same view with MVVM and a quick look at some of the communication between view and view model that we'll get into in more detail later in the course.

Hooking up Views and ViewModels in MVVM
Hi, and welcome back to WPF/MVVM In Depth. In this module I'm going to cover different ways that you can get your views hooked up to their view models, as well as how data binding is used to expose data from your view models to your views. I'll start by covering several ways to do View-First construction where the view is constructed first, and the view takes care of constructing and hooking up its own view model. Then I'll briefly talk about data binding, just to make sure it's clear how MVVM relies on data binding, and uses it to flow data between the view and the view model. Finally, I'll cover the ViewModel-First construction approach, where you use data templates to create the view, based on an instance of a view model being placed into a data binding context.

View/ViewModel Communication in WPF
Hi, and welcome back to this fourth module in WPF/MVVM In Depth. The focus in this module will be on how to add interactivity to your MVVM apps, how to cleanly call logic that's implemented in your view model when something happens in the view, as well as letting the view know if something happened behind the scenes in your view model, model objects, or client services. And you'll see that all of this is done maintaining that loose coupling and good structuring that's at the heart of the MVVM pattern. First up, we'll talk about commands a bit more. You saw a quick example of using a command to invoke some view model logic in the demos of the second module. In this module I'll go a bit deeper, looking at how things get hooked up, what happens under the covers during that hookup, how to use command enabling, and keyboard shortcuts. Then we'll take a look at attached properties and behaviors, covering what the relationship between them is, what their general capabilities are, and how to use them in the context of MVVM as another means of setting up communication paths between the view elements and view model logic, or vice versa. We'll finish up this module with a review of how property change notifications work with databinding in WPF, and show how they can be used as a signaling mechanism from the view model to make things happen in the view at the appropriate time.

Applied MVVM Part 1 - Hierarchies and Navigation
Hello and welcome back to WPF/MVVM In Depth. In the remaining two modules of this course, I'm going to start building out a few more fully-functional use-cases from start to finish, and in doing so will hit on a number of other design considerations and things you'll need to know how to tackle when using the MVVM pattern. In this module we'll start with a few concepts first, including how you should name your MVVM components, and a couple of choices on how you should locate them. Then I'll talk about the concept of hierarchical MVVM and how it ties in with navigation where you compose your app from hierarchies of Views and ViewModels. From there, we'll dive right into writing code and start building out several use cases for a pizza order management app. We'll build out use cases, including hierarchical MVVM and navigation, getting some data on the screen in a listing, and being able to switch to other views and pass navigation parameters. That app development will continue into the next module, as well as to finish out the rest of the course.

Applied MVVM Part 2 - Validation and Dependency Injection
Hi and welcome back to this final module of WPF/MVVM In Depth. In this module we're going to continue to build out the use cases surrounding customers in our pizza order management app. This will include fleshing out some data entry for adding and editing customers by leveraging the scaffolding of data-centric views that's available in Visual Studio. Also, anytime you're accepting input from a user, you should also be validating that input. So we'll look at a clean way to do validation with what WPF bindings already support, but tying it into your MVVM components. When view models take dependencies on client services, you'll want to keep those dependencies loosely coupled as well, so I'll talk a little bit about dependency injection and show you how to use it in the demos. Finally, I'll close out with some brief coverage of what MVVM frameworks or toolkits you should take a look at to save yourself some effort in using the MVVM pattern.