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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With