Reputation: 4550
I have a couple of questions regarding showing the Hamburger icon which shows the Flyout and going to the previous page.
I Created the default app in Visual Studio and added a second page
I registered the second page in AppShell.xaml.cs
Routing.RegisterRoute(nameof(SecondPage), typeof(SecondPage));
In MainPage.xaml, I added a button which when pressed sends the user to the second page
await Shell.Current.GoToAsync(nameof(SecondPage), true);
This all works.
But, while on the first page we can see the Hamburger icon
When arriving on the second page from the button click, we see a back button and no hamburger icon
You can still swipe from the left to show the Flyout but How do I show the hamburger icon on the second page?
My second question is if I add a link to the second page in the Flyout - AppShell.xaml
<ShellContent
Title="Second Page"
ContentTemplate="{DataTemplate local:SecondPage}"
Route="SecondPage" />
When it is clicked then we DO see the hamburger icon
but no back button and if you click back using Android's Back button then it exits the App. So, my second quesiont is How do I make a click on the menu behave like the button being clicked.
Upvotes: 8
Views: 5791
Reputation: 1
try sliding your finger to the right when you navigate to the second page through button
Upvotes: -2
Reputation: 879
That's because the flyout does absolute routing but your code does relative routing and maintains the navigation stack.
If you want to programmatically get the same behavior, you need to switch to absolute routing.
await Shell.Current.GoToAsync($"//{nameof(SecondPage)}");
Read more about Shell navigation in the. NET MAUI documentation
Upvotes: 6