Navigate to another shell with another menu

Hikari91Hikari91 ITMember ✭✭✭

Hi all,
I need to navigate from the main shell to another one that have a different menu.

What is the best way to do this?

I have edited the base shell project that VisualStudio makes and the result is attached.

I managed to open a second shell but it have double header on iOS and doesn't have the hamburger icon on Android.
Android
iOS

There is another way to do it?

Attached the sample.

Thank you! :smile:

Answers

  • JarvanJarvan Member, Xamarin Team Xamurai

    Navigation can be performed by specifying a valid absolute URI as an argument to the GoToAsync method:
    https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/shell/navigation#perform-navigation

    Refer to the code:

    await (App.Current.MainPage as Xamarin.Forms.Shell).GoToAsync("app://com.companyname/_Shell/shell_item/about", true);
    

    AppShell.xaml

    <Shell xmlns="http://xamarin.com/schemas/2014/forms" 
           xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
           xmlns:local="clr-namespace:_Shell.Views"
           ...
           RouteHost="companyname.com"
           RouteScheme="app"
           Route="_Shell"
           ...
           >
        ...
        <ShellItem Route="shell_item">
            <ShellSection Title="Browse" Icon="tab_feed.png">
                <ShellContent ContentTemplate="{DataTemplate local:ItemsPage}" />
            </ShellSection>
            <ShellSection Route="about" Title="About" Icon="tab_about.png">
                <ShellContent ContentTemplate="{DataTemplate local:AboutPage}" />
            </ShellSection>
        </ShellItem>
    </Shell>
    
  • Hikari91Hikari91 ITMember ✭✭✭

    @yelinzh said:
    Navigation can be performed by specifying a valid absolute URI as an argument to the GoToAsync method:
    https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/shell/navigation#perform-navigation

    Refer to the code:

    await (App.Current.MainPage as Xamarin.Forms.Shell).GoToAsync("app://com.companyname/_Shell/shell_item/about", true);
    

    AppShell.xaml

    <Shell xmlns="http://xamarin.com/schemas/2014/forms" 
           xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
           xmlns:local="clr-namespace:_Shell.Views"
           ...
           RouteHost="companyname.com"
           RouteScheme="app"
           Route="_Shell"
           ...
           >
        ...
        <ShellItem Route="shell_item">
            <ShellSection Title="Browse" Icon="tab_feed.png">
                <ShellContent ContentTemplate="{DataTemplate local:ItemsPage}" />
            </ShellSection>
            <ShellSection Route="about" Title="About" Icon="tab_about.png">
                <ShellContent ContentTemplate="{DataTemplate local:AboutPage}" />
            </ShellSection>
        </ShellItem>
    </Shell>
    

    Hi,
    thank you for the reply but I have see this guide and doesn't help me.

    If you download and start the attached project, you can see that I have opened the new Shell using
    await Navigation.PushModalAsync(new NavigationPage(new Shell2()));

    :smile:

Sign In or Register to comment.