'How do I go to the Shell page and leave the menu button?

If I navigate to other pages from the Shell menu items then I have the option to open the pull-out menu again. And if I go to the page from the code inside, then the menu button at the top left is no longer there.

 await Shell.Current.GoToAsync("step");

How to open a page from the code and what would be in the open page was the shell menu button?



Solution 1:[1]

The edit queue is always full! So here is my expansion of Wendy's answer:

TLDR:

Essentially the Hamburger Nav is only visible on Pages that are added or registered to the Shell or one of its child BaseShellItems and thus are apart of the Shell Visual Hierarchy -> If the Page is registered via AppShell.xaml (can also be added programmatically) then the Page is being added to a BaseShellItem and is apart of the Shell Visual Hierarchy.


There are several ways to register a page for navigation and that determines whether the page is displayed with a hamburger:

  1. If register a page via the AppShell.xaml like:
      <ShellContent
            Title="This is Page1"
            ContentTemplate="{DataTemplate local:Page1}"
            Icon="tab_about.png"
            Route="Page1" />

you can navigate with the parameter like below.

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

When you navigate, the hamburger icon would still be there, as the page is added to a BaseShellItem( BaseShellItem->ShellContent).

  1. If you register a page not in the AppShell.xaml but via Routing:
Routing.RegisterRoute(nameof(page1), typeof(Page1));

and navigate to the page, it would cover all the page and the hamburger icon would not show, as its not added to a BaseShellItem. But you could go back to the Shell with the back button on top left.

  1. You can register the Page (as of Xamarin.Forms 5) by adding it to a BaseShellItem but not have it shown in the Shell's menus and get the page to have have the hamburger nav menu by adding it as to a FlyoutItem in the AppShell.xaml and using FlyoutItemIsVisible="False":
<FlyoutItem
        Title="Stat Page"
        FlyoutItemIsVisible="False"
        IsEnabled="True">

    <ShellContent
            Title="Page1"
            ContentTemplate="{DataTemplate local:Page1}"
            Icon="tab_about.png"
            Route="about" />
</FlyoutItem>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1