Building an application using the MVVM pattern
MVVM stands for Model, View, and ViewModel, which is a pattern that facilitates the separation between the GUI (Graphical user interface) from the business logic. It means that a designer and developer can work together, without any hassle.
In this pattern, the model is the data that gets displayed in the view with the help of ViewModel. In this recipe, we will learn how to create an MVVM application, expose the properties from the ViewModel to the associated view, and display records without writing any code in the XAML code behind file.
Getting ready
Let's open the Visual Studio IDE and create a new project, called CH07.MVVMDemo
, based on the WPF app template.
How to do it...
Once the project has been created, follow these steps to construct the project for the MVVM standard (not mandatory) and build a sample demo using the MVVM pattern:
- Each WPF app project has a
MainWindow.xaml
. From theSolution Explorer
, let's delete the default file. - Inside...