7 Pages and navigation

 

This chapter covers:

  • How to break your app up into pages using the ContentPage base class
  • How to use the navigation paradigms supported by .NET MAUI to navigate between different pages in your app
  • Using Shell to simplify organising the pages in your app
  • Passing data between pages when navigating

So far, we’ve built a handful of apps, all using a single page. This has worked well for the sample apps we’ve been building and works equally well for several commercial apps in the real world. But often, you need more than one page, for example to distinguish different areas of an app or logically group functionality. This becomes especially necessary with non-trivial apps when they grow too much to cram everything into a single screen.

In this chapter we’ll look at navigation paradigms and the different ways that .NET MAUI supports providing multiple pages in your apps and navigating between them.

7.1 ContentPage

ContentPage is the most important Page type, in that the other Page types are just containers that provide different navigation paradigms that offer a way to present a ContentPage.

7.2 Common Page Properties

7.2.1 IconImageSource

7.2.2 Background Images

7.2.3 Padding

7.2.4 Title

7.2.5 MenuBarItems

7.3 Common Page Lifecycle Methods

7.3.1 OnAppearing

7.3.2 OnDisappearing

7.3.3 OnNavigatedTo and OnNavigatedFrom

7.3.4 OnSizeAllocated

7.3.5 BackButtonPressed

7.4 Navigation in .NET MAUI

7.4.1 Scenario: The MauiStockTake app

7.4.2 Features of the MauiStockTake app

7.4.3 Hierarchical Navigation

7.4.4 Flyout Navigation

7.4.5 Tabbed Navigation

7.5 Introducing Shell

7.5.1 The Flyout Menu

7.5.2 Tabs

7.5.3 Getting Started with MauiStockTake

sitemap