Category: SimpleMVVM

SimpleMVVM, Part 9: The EditProductPage view model

As a reminder – that’s how the EditProductPage looks: First of all we need a view model class. Create a class named EditProductPageVM, and derive it from the class PageVM. Add a constructor with parameters of type ISystemConnector and PageFrameVM and and pass the parameters to the base class constructor:

Create a new RelayCommand…


SimpleMVVM, Part 8: The EditCustomerPage view model

We’ll start with the EditCustomerPage. As a reminder – that’s how it looks: First of all we need a view model class. Create a class named EditCustomerPageVM, and derive it from the class PageVM. Add a constructor with a parameter of type ISystemConnector and pass the parameter to the base class constructor:

The page…


SimpleMVVM, Part 7: Change notification

The basic idea of MVVM is, that view models expose properties to which the views bind. Ordinary C# properties don’t come with a mechanism to inform listeners of changes, so the binding mechanism of WPF relies on an interface named INotifyPropertyChanged. This interface consists of only one event: PropertyChanged. Since every view model should be…


SimpleMVVM, Part 6: The MainMenuPage view model

Our first task with the new view model system will be to connect the button clicks in the main menu with the display of the corresponding pages. The quit button To start with something simple, we’ll implement the quit button. (We’ll soon see that it’s not as simple as it seems…) The communication between the…


SimpleMVVM, Part 5: The first test

Since we have a system class that ties everything together, we can now write the first test. Add a new Unit Test Project to your solution; name it SimpleMVVMTests. Rename the pregenerated test method to InitTest() and put the following code in it:

Note: You will have to add a reference to the main…


SimpleMVVM, Part 4: Implementing the page frame

You might have noticed that we forgot the “Main Menu” button in the page frame. Let’s add a button to the data template of the page frame:

If you run the program, you’ll see this: The button is far too long and the font is far too small. Add another style for the button…


SimpleMVVM, Part 3: The basic view model system

In this part we will build the basic view model system, so we can display pages and start with a simple unit test. The idea of a view model layer is to move the logic from the view layer (the XAML files) to a new layer to make it testable (and potentially reusable – even…


SimpleMVVM, Part 2: The product edit and customer edit pages

In this part we’ll build the XAMLs for the two edit windows. They are fairly similar so we can create them in one go. Remember, this is what the edit customer page should look like: We’ll build the page with a UniformGrid with two columns – the ListBox left and the TextBoxes right. We do…


SimpleMVVM, Part 1: The main window

We’ll start with the XAMLs for this project. Although this is actually a straight forward task, there are a couple of issues that one should keep an eye on. As a reminder – this is what we want: You could now start with a window and put the buttons in there. But it’s a better…


Simple MVVM: An example

The following posts build an example WPF application with a MVVM architecture which primary focus lies on simplicity. It does not use any other frameworks or libraries. It is built with plain WPF. It will show that a MVVM application can be simple and fairly easy to understand, and that frameworks like PRISM aren’t needed…