4

MVVM and Controls

In Chapter 3, we examined the fundamentals of .NET MAUI, but our code was in the code-behind files associated with XAML files. It is time, though, to turn our attention to the consensus architecture for .NET MAUI.

Model-View-ViewModel (MVVM) is not a tool or a platform but an architecture. Simply put, it is a way of organizing your code and thinking to optimize the creation of .NET MAUI applications and to facilitate unit testing (see Chapter 9).

At its simplest, MVVM consists of three sets of files, that is three namespaces, which essentially means three folders (with subfolders as needed). Taken in turn, Model is the set of classes that define the shape of your data. This just means that the classes that represent data ...

Get .NET MAUI for C# Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.