Navigate To other Shell Page when tabar is Hide

LOYER LOUIS 21 Reputation points
2020-11-27T08:25:27.903+00:00

Hello everyone who look at this post,
I'm having a bad problem in my Xamarin.Forms application using Shell for navigation.
(here is a link to shell documentation: https://learn.microsoft.com/xamarin/xamarin-forms/app-fundamentals/shell/ )

I have 3 diffrents pages in my application and they all are connected with the Shell Tabar component.
But for aesthetics reasons, in my home page, i want to disable tabar and navbar and replace the navigation of my tabar with buttons of my home page.
here is some pics to help u understand:

43155-capture-decran-2020-11-27-a-091232.png

Look, on this page, navbar and tabar are disable and with buttons (orange, blue and purple butoons), i want to access to thoses page:

43120-capture-decran-2020-11-27-a-091634.png

Thoses page have the navbar and tabar Able.

If someone know some behind code or XAML code to navigate With my buttons to other page in Shell, please help me to resolve my problem.
Thank u a lot for taking care about my post.

(I'm sorry for my english, u know how bad are french people at learning other languages :'). )

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,294 questions
0 comments No comments
{count} votes

Accepted answer
  1. Lucas Zhang - MSFT 336 Reputation points
    2020-11-27T10:50:38.413+00:00

    In Button Click Event

       await (App.Current.MainPage as Xamarin.Forms.Shell).GoToAsync("//tabbar/tab/about", true);
    

    **AppShell.xaml: **Set the route.****

    You need to set the route as you want , my code is just for demo

    <TabBar Route="tabbar">
        <Tab Title="Browse" Icon="tab_feed.png">
            <ShellContent ContentTemplate="{DataTemplate local:ItemsPage}" />
        </Tab>
    
        <Tab Title="About" Icon="tab_about.png" Route="tab">
            <ShellContent Route="about" ContentTemplate="{DataTemplate local:AboutPage}" />
        </Tab>
    </TabBar>
    

2 additional answers

Sort by: Most helpful
  1. Lucas Zhang - MSFT 336 Reputation points
    2020-11-27T09:14:41.543+00:00

    Hello,

    Welcome to our Microsoft Q&A platform!

    You could invoke the following lines

    in Shell

       public AppShell()  
        {  
            InitializeComponent();  
         
         
            Shell.SetTabBarIsVisible(this,false);  
            Shell.SetNavBarIsVisible(this, false);  
         
       }  
    

    And set it as true in other page if you want to display them in specific ContentPage .

    If you want to switch tab in code , you could set the property TabIndex

       Shell.Current.TabIndex = 1;  
    

    For more details about navigation in Shell you could refer
    https://learn.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/shell/navigation

    Best Regards,

    Lucas Zhang


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  2. LOYER LOUIS 21 Reputation points
    2020-11-27T10:42:02.197+00:00

    Thank you a lot for ur answer Mate ! i still need some explaination :/

    Here is the code i tried to add with my button:

    43302-capture-decran-2020-11-27-a-113855.png

    43238-capture-decran-2020-11-27-a-113827.png

    but it's seems that, nothing change... my tabindex value is setted to "2" but my tabar doean't nav to the second page ? Did i implement it wrong ?