How to switch pages in the Xamarin Shell without a back button?

1.5k Views Asked by At

I want to make a home button at the top of the Shell-based APP. (Referring to the Xanimals app.)

The purpose of this home button is to move to one of the specific Routined pages in the Shell.

The gotoasync() function adds the previous page to the navigation stack by default, and the Backward button is enabled. I don't want the back button, I just want to move like when you press the flyout button in Shell structure.

Please help me.

2

There are 2 best solutions below

2
On BEST ANSWER

Try the below method :

in your home button click event:

Shell.Current.CurrentItem.CurrentItem.Items.Add(Your new Page);
Shell.Current.CurrentItem.CurrentItem.Items.RemoveAt(0);
0
On

You could try this method which switches to a different navigation stack; assuming the home view is registered with a route name of home in your AppShell.xaml

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

Here's a reference to all route formats:

https://learn.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/shell/navigation#absolute-routes