0

I am using Xamarin.Forms Shell and I have bottom Tab Bar navigation with no Flyout.

<TabBar Route="tabs">
        <Tab Title="Page1" Route="page1" Icon="page1.png">
            <ShellContent ContentTemplate="{DataTemplate local:Page1}" />
        </Tab>
        <Tab Title="Page2" Route="page2" Icon="page2.png">
            <ShellContent Route="page2A" ContentTemplate="{DataTemplate local:Page2A}" />
            <ShellContent Route="page2B" ContentTemplate="{DataTemplate local:Page2B}" />
        </Tab>
        <Tab Title="Page3" Route="page3" Icon="page3.png">
            <ShellContent ContentTemplate="{DataTemplate local:Page3}" />
        </Tab>
</TabBar>

I want the content of the page2 tab to be programatically determined using GoToAsync("tabs/page2/page2A") and GoToAsync("tabs/page2/page2B").

This way there should be persistence when the user navigates between tabs as to which ShellContent is displayed (e.g. page2A or page2B).

The behaviour works fine, but I want to hide the TOP Tab Bar that allows the user to navigate between the two ShellContent pages. Is there a way to do that in Xamarin.Forms Shell?

Ken White
  • 123,280
  • 14
  • 225
  • 444
TomEverin
  • 415
  • 1
  • 5
  • 12
  • ** I want to hide the TOP Tab Bar that allows the user to navigate between the two ShellContent pages.**, I an not sure what you mean, you mean that you don't want to user to choose Page2A and Page2B, just using `GoToAsync("tabs/page2/page2A")` and `GoToAsync("tabs/page2/page2B")` to navigate? Can you try to use `Shell.NavBarIsVisible="False"` for ShellContent. – Cherry Bu - MSFT May 21 '20 at 02:53
  • No, `NavBarIsVisible="False"` hides the NavBar, but the top tabs remain visible. Another way to think of it is: I want to replace a ``'s `` with different `` at runtime. If I could hide the `top tab bar`, then this functionality would be trivial by simply adding multiple `` elements to the ``. – TomEverin May 21 '20 at 10:10

1 Answers1

0

I can't find a way to do this with routes. The desired behaviour can be achieved with:

(Shell).CurrentItem.Navigation.PushAsync({desired_content});

By pushing onto the CurrentItem's Navigation the content within a tab can be updated, and will persist while the user navigates between bottom-bar tabs.

TomEverin
  • 415
  • 1
  • 5
  • 12
  • Seems that you have one way to solve your problem, please remember to mark your reply as answer, it is beneficial to others to find this reply. – Cherry Bu - MSFT May 22 '20 at 07:27