adinas
adinas

Reputation: 4550

.NET MAUI Shell - Show Hamburger icon after navigation

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

enter image description here

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 enter image description here

When arriving on the second page from the button click, we see a back button and no hamburger icon

enter image description here

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

enter image description here

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

Answers (2)

try sliding your finger to the right when you navigate to the second page through button

Upvotes: -2

Tundebabzy
Tundebabzy

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

Related Questions