question

LOYERLOUIS-5614 avatar image
0 Votes"
LOYERLOUIS-5614 asked ·

Navigate To other Shell Page when tabar is Hide

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://docs.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 :'). )

dotnet-xamarinformsdotnet-xamarinforms-xamldotnet-androiddotnet-ios
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

LucasZhang-MSFT avatar image
0 Votes"
LucasZhang-MSFT answered ·

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>



· 1 ·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks u LucasZhang, that was exactly what i needed. U perfectly resolved my problem !

0 Votes 0 ·
LucasZhang-MSFT avatar image
0 Votes"
LucasZhang-MSFT answered ·

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://docs.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.





·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

LOYERLOUIS-5614 avatar image
0 Votes"
LOYERLOUIS-5614 answered ·

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 ?



· 1 ·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

In Button_Clicked

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

In your ShellPage.xaml make sure your Tabs have routes setup. Note the Route for FilesPage. The above command needs this route set.

 <TabBar>
     <ShellContent Title="Files" Route="FilesPage" ContentTemplate="{DataTemplate views:FilesPage}" />
     <ShellContent Title="Play" Route="MP3Player" ContentTemplate="{DataTemplate views:MP3Player}" />
     <ShellContent Title="Fldrs" Route="FoldersPage" ContentTemplate="{DataTemplate views:FoldersPage}" />
 </TabBar>
0 Votes 0 ·