0
votes

I am using the Shell template from VS2019 in a Xamarin Forms app.I have two pages listed in the shell flyout.

<FlyoutItem Title="Home" Icon="icon_about.png">
       <ShellContent Route="HomePage" ContentTemplate="{DataTemplate local:HomePage}" />
</FlyoutItem>
<FlyoutItem Title="Logoff time" Icon="icon_about.png">
       <ShellContent  Route="SecondPage" ContentTemplate="{DataTemplate 
        local:SecondPage}" />
</FlyoutItem>

Using the hamburger menu I navigate away from the Homepage to another page SecondPage. I have a button on the SecondPage which perform an action and from that action I want to navigate back to the HomePage. When I use this code:

var route = $"{nameof(HomePage)}";
await Shell.Current.GoToAsync(route);

The HomePage shows but there is a back button instead of the hamburger menu. If I tap the hamburger icon the page navigates back to the SecondPage. How do I navgate from SecondPage to HomePage and show the hamburger icon?

2

2 Answers

1
votes

With so little information (not knowing the details of how your navigation is implemented) it's hard to help you. But the first things that come to mind are the following you could try.

Try one of the following for popping the SecondPage and navigating back to:

await Shell.Current.Navigation.PopAsync();

or

await Shell.Current.Navigation.PopModalAsync();

And if you have a navigation bar with a back button that you don't want then try this in the HomePage.xaml

NavigationPage.HasNvaigationBar="False"

or

Shell.NavBarIsVisible="False"
0
votes

The two

//

before the route will accomplish my aims.This resets the root page apparently so HomePage once again become the root page.

var route = $"//{nameof(HomePage)}"