liveBook · Manning

Navigation state

As explained in .NET MAUI in Action

Navigation state is the data associated with the current or requested navigation destination and its transition.

Navigation state is a dictionary of <string, object> values carried between .NET MAUI Shell pages during navigation. It lets a destination receive data without encoding everything in a route string. section 7.5.5 section 7.6

A typical navigation-state flow is:

  • Create the destination model, such as a Product object. section 7.5.5
  • Register a route for the destination page. section 7.5.5
  • Place the object in a Dictionary<string, object> using a key such as Product. section 7.5.5
  • Call Shell.Current.GoToAsync with the route and dictionary. section 7.5.5
  • Decorate the receiving page or binding context with QueryProperty and bind displayed values to page properties. section 7.5.5

Passing a product to ProductPage

var pageParams = new Dictionary<string, object> { { "Product", product } }; await Shell.Current.GoToAsync("productdetails", pageParams); The destination declares [QueryProperty(nameof(Product), nameof(Product))], receives the Product property, copies its values into bindable properties, and displays them with XAML Labels.

How .NET MAUI in Action covers it

How deep it goes
Explains dictionary construction, route navigation, QueryProperty reception, property assignment, and XAML binding through a product example.
Examples
Uses a Product model, InputPage button, productdetails route, navigation dictionary, ProductPage, and bound product labels.
What it assumes
Assumes basic C#, XAML, .NET MAUI pages, Shell routing, properties, and data binding.
What you can do after
Build it from scratch by registering a Shell route, passing a typed object in a dictionary, receiving it with QueryProperty, and binding its values.
How it connects
Connects Shell navigation, route parameters, query strings, QueryProperty, data binding, and programmatic navigation.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of .NET MAUI in Action. The section links point to the parts of the book it draws on.