.Net Maui Windows: Is there a way to navigate directly to a page on the navigation stack?

Yusuf Groenewald 0 Reputation points
2023-06-14T17:11:58.6833333+00:00

I have a .Net Maui application targeting the Windows platform (net7) using Visual Studio 17.6.2.

All the routes are registered and throughout the entire application I use Shell navigation, e.g.

...
Routing.RegisterRoute(nameof(MatchListPage), typeof(MatchListPage));
Routing.RegisterRoute(nameof(MatchAddEditPage), typeof(MatchAddEditPage));
Routing.RegisterRoute(nameof(PlayersListPage), typeof(PlayersListPage));
Routing.RegisterRoute(nameof(PlayerAddEditPage), typeof(PlayerAddEditPage));
...
await Shell.Current.GoToAsync(nameof(MatchListPage));
...
await Shell.Current.GoToAsync(nameof(MatchAddEditPage), true,             
	new Dictionary<string, object>             
	{                     
		{ "Match", new MatchViewModel() }
	});
...
await Shell.Current.GoToAsync(nameof(PlayersListPage));
...
await Shell.Current.GoToAsync($"{nameof(PlayerAddEditPage)}?id=0");

An example of the current navigation problem:
Step 1. I click the menu item to navigate to the "PlayersListPage" page, which works fine.
Step 2. I click the menu item to navigate to the "PlayerAddEditPage" page, which works fine.
Step 3. I click the menu item to navigate to the "MatchListPage" page. However, the application goes to the "PlayersListPage" page instead of going to the "MatchListPage" page.
Step 4: I again click menu item to navigate to the "MatchListPage" page. The application now goes to the "MatchListPage" page.

My challenge is, how do I navigate directly to a page on the navigation stack?

Any help or advice will be appreciated. Thanks!

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
4,149 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.