Create your ViewModels
First we're going to create a couple of base classes for our PageViewModels and ViewModels. It's not necessary, but it makes life much easier if we later on want to insert our own base class functionality. If you do not wish to do this then you can simply derive your ViewModel
classes directly from the library implementations (or not - MvvmZero
does not require you use its base classes)
In your Mvvm/PageViewModels
folder, add the following abstract
class:
using FunctionZero.Maui.MvvmZero;
namespace MvvmZeroTutorial.Mvvm.PageViewModels
{
public abstract class BasePageVm : MvvmZeroBasePageVm
{
}
}
Similarly, in your Mvvm/ViewModels
folder, add the following abstract
class:
using FunctionZero.Maui.MvvmZero;
namespace MvvmZeroTutorial.Mvvm.ViewModels
{
public abstract class BaseVm : MvvmZeroBaseVm
{
}
}
Now we want to create a ViewModel
for each of the ContentPages
. In the Mvvm/PageViewModels
folder, add ReadyPageVm

ViewModel
Make the class public
and derive from our base implementation for a PageViewModel
:
namespace MvvmZeroTutorial.Mvvm.PageViewModels
{
public class ReadyPageVm : BasePageVm
{
}
}
Repeat the process for SteadyPageVm
, GoPageVm
and DetailPageVm
And here we are:

ViewModels
added to the projectNext we're going to register our Pages
and ViewModels
so they can be presented.
Last updated