.NET MAUI Documentation

.NET MAUI Navigation Tutorials

Master the art of navigating between pages and views in your .NET MAUI applications. This section covers various navigation patterns, from simple page-to-page transitions to complex hierarchical navigation and shell navigation.

Key Concepts

Understanding these core concepts will help you build robust navigation experiences:

Navigation Stack

The navigation stack is a Last-In, First-Out (LIFO) collection of pages that the application is currently navigating through. When you navigate to a new page using Navigation.PushAsync(newPage), the new page is added to the top of the stack. When you navigate back using Navigation.PopAsync(), the top page is removed from the stack, and the previous page becomes visible.

Navigation Service

For more complex applications, implementing a dedicated navigation service can abstract navigation logic, making your code cleaner and more maintainable. This service often uses dependency injection to provide navigation capabilities throughout your app.

.NET MAUI Shell

Shell simplifies the development of cross-platform applications by providing a standard navigation experience. It enables features like tabbed interfaces, flyout menus, and URI-based routing out-of-the-box, reducing boilerplate code.

Getting Started with Navigation

To begin navigating, you typically need to obtain an instance of the INavigation interface. In most scenarios within a page, you can access it via the Navigation property of the ContentPage:


// Example in a ContentPage code-behind
async void OnNavigateToNextPageClicked(object sender, EventArgs e)
{
    await Navigation.PushAsync(new NextPage());
}
                

For scenarios outside of a page, such as in ViewModels, you'll often inject a navigation service that provides access to the INavigation interface or implements its own navigation patterns.