Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why Back Button is hidden in Maui?

Tags:

maui

I have a .Net MAUI application with Page A and Page B.

I want to move from Page A >>> Page B.

When I move using the following code, I have a back button (which is the desired behavior in my case) :

await Navigation.PushAsync(new MyPage());

However if I move to the other page using the following code, I don't have a back button :

await Shell.Current.GoToAsync("//MyPage");

For some other reasons I need to use navigation through Shell.

Why don't I have a back button when navigating using Shell?

like image 244
Thomas Carlton Avatar asked Oct 16 '25 10:10

Thomas Carlton


1 Answers

Here is the answer :

Instead of

await Shell.Current.GoToAsync("//MyPage");

I should do

await Shell.Current.GoToAsync("/MyPage");

Reason :

According to the official documentation here :

route : The route hierarchy will be searched for the specified route, upwards from the current position. The matching page will be pushed to the navigation stack.
/route : The route hierarchy will be searched from the specified route, downwards from the current position. The matching page will be pushed to the navigation stack.
//route : The route hierarchy will be searched for the specified route, upwards from the current position. The matching page will replace the navigation stack.
///route : The route hierarchy will be searched for the specified route, downwards from the current position. The matching page will replace the navigation stack.
like image 89
Thomas Carlton Avatar answered Oct 19 '25 12:10

Thomas Carlton