Reputation: 954
I have a problem. In my app I have the following structure
Now I want to go from a page inside the TabbedPage
to another page with Navigation.PushAsync()
, but when I do that, I get the new page on screen with the TabbedPageBar
. That is not what I want, I want to use the root NavigationPage
to go to another page, so when click back I come back at the NavigationPage
inside the TabbedPage
.
Here is some code:
App.xaml.cs:
MainPage = new NavigationPage (new MainPage());
MainPage.xaml:
<?xml version="1.0" encoding="utf-8" ?>
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:views="clr-namespace:MyApp.Views"
mc:Ignorable="d"
x:Class="MyApp.Views.MainPage"
xmlns:android="clr-namespace:Xamarin.Forms.PlatformConfiguration.AndroidSpecific;assembly=Xamarin.Forms.Core"
android:TabbedPage.ToolbarPlacement="Bottom"
BarBackgroundColor="White"
BarTextColor="Black"
android:TabbedPage.BarItemColor="#B2B2B2"
android:TabbedPage.BarSelectedItemColor="#56D7A5"
android:TabbedPage.IsSwipePagingEnabled="False">
<TabbedPage.Children>
<NavigationPage Title="Page1" IconImageSource="navbar_page1">
<x:Arguments>
<views:page1 NavigationPage.HasNavigationBar="False" />
</x:Arguments>
</NavigationPage>
</TabbedPage.Children>
</TabbedPage>
page1.xaml.cs:
private void OpenPage()
{
Navigation.PushAsync(new page2());
}
So, to be clear, the result I have now, is that page2 has the TabbedPageBar
, so I need to use the NavigationPage
of the root, so the TabbedPageBar
goes away, but I have no idea how to do that.
Can someone help me
Upvotes: 0
Views: 297
Reputation: 1
As I understand in your page1.xaml.cs you are calling the Navigation created for the page1 and since i understand you want to navigate inside the Navigation created for the MainPage (that's of Type TabbedPage) I belive the solution to your problem is to replace Navigation.PushAsync(new page2());
with Application.Current.MainPage.Navigation.PushAsync(new Page2())
Upvotes: 0
Reputation: 18861
It is not a good design to put the Tabbed Page in a NavigationPage .It will has two navigation bar in the app .
Just set the Tabbed Page as MainPage directly .
MainPage = new MainPage();
Upvotes: 1