Maintaining a clean separation between application logic and UI helps to address numerous development and design issues and can make your application much easier to test, maintain, and evolve.It can also greatly improve code re-use opportunities and allows developers and UI designers to more easily collaborate when developing their respective parts of the application.

If you are continuing from the Simple MVVM Example, I moved the Product View out of a Resource Dictionary and into a User Control to make this simpler.

The last thing to do is change to make Application View and Application View Model our startup, instead of Product View/Product View Model. You can download the source code for this sample from here.

This allows me to use Data Templates to tell WPF how to draw each IPage View Model.

In this example, I’m using an Items Control to display my Page View Models.

The following illustration shows the three MVVM classes and their interaction.

Like with all separated presentation patterns, the key to using the MVVM pattern effectively lies in understanding the appropriate way to factor your application's code into the correct classes, and in understanding the ways in which these classes interact in various scenarios.When I first started out with MVVM, I was lost about how you should navigate between pages.I’m a firm believer in using View Models to do everything (unless it’s View-specific code), and that the UI is simply a user-friendly interface for your View Models.I did not want to create a button on a page that has any kind of code-behind to switch pages, and I didn’t like the idea of my navigation being spread out throughout all the View Models.I finally came to realize the solution was simple: I needed a View Model for the Application itself, which contained the application state, such as the Current Page.Each item is drawn using a Button, and the Button’s Command property is bound to the Change Page Command.