Try It Yourself

Practice what you learned in this chapter in an interactive code playground.

MVVM playground

The interactive playground below contains a .NET MAUI project that was set up with the MVVM architectural pattern. We can apply modifications to it and see how they would affect the structure of the compiled application.

Adding a Model

We'll add a Model to our application so the data can be persisted. This is what we'll do in the fully interactive code editor below.

Our Model will store the latest count. By convention, Model classes are stored in a folder called Models, so we have one in the playground. It contains the CounterModel.cs file with only an empty class definition. We'll populate it with the following content:

Get hands-on with 1400+ tech skills courses.