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.
1条答案
按热度按时间nafvub8i1#
这是因为弹出按钮执行绝对路由,而您的代码执行相对路由并维护导航堆栈。
如果您希望以编程方式获得相同的行为,则需要切换到绝对路由。
await Shell.Current.GoToAsync($"//{nameof(SecondPage)}");
阅读更多关于the. NET MAUI documentation中的Shell导航