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 are held in the model.
View
is, in simple words, the page that the user sees.
ViewModel
is where all the action happens. It is the set of classes that manage the logic of your program and that contain the properties that are presented...