Navigating to different pages using MAUI and Shell

By default MAUI includes the Shell (see AppShell.xaml/AppShell.xaml.cs). We can use method on this object to navigate to pages in MAUI, for example if we add a simple AboutPage and want to navigate to it from a our view model we can write something like this

[RelayCommand]
private async Task About() => await AppShell.Current.GoToAsync(nameof(AboutPage));

Obviously the nameof(AboutPage) maps the the name we’ll be registering for the AboutPage.

Now we need to register the page within the shell, so go to AppShell.xaml.cs and add the following

Routing.RegisterRoute(nameof(AboutPage), typeof(AboutPage));

That’s all we need to do.