Advertisement
Beginner .NET MAUI, Shell Navigation

How do you navigate between pages using Shell?

Short answer

Call Shell.Current.GoToAsync with a route. Absolute routes (starting //) reset the navigation stack to a registered top-level route; relative routes push onto the current stack. Routes are registered via Routing.RegisterRoute or implicitly by ShellContent.

Save .NET MAUI mock interview
Advertisement
AModel answer
Call Shell.Current.GoToAsync with a route. Absolute routes (starting //) reset the navigation stack to a registered top-level route; relative routes push onto the current stack. Routes are registered via Routing.RegisterRoute or implicitly by ShellContent.
await Shell.Current.GoToAsync("details");        // push
await Shell.Current.GoToAsync("//home");          // reset to root
await Shell.Current.GoToAsync("..");              // go back
Real-world example
Tapping a list item pushes a details route, and a logout action uses //login to clear the stack and return to sign-in.
Likely follow-ups
  • What's the difference between // and relative routes? | How do you go back?
Related topics