简体   繁体   中英

Xamarin.Forms Navigate from TabbedPage

I am new at Xamarin.Forms, I came from android. I found on Xamarin.Forms Docs that is not recommended to put a TabbedPage in a NavigationPage so what should I do to navigate to another page. And I don't want to navigate from one of the tabbedPage children, but to navigate from the tabbed page to a whole new page?

not recommended to put a TabbedPage in a NavigationPage

That means we would better set the MainPage of the App as a TabbedPage directly like

public App()
{
    InitializeComponent();

    MainPage = new TabbedPage(); // it's better than MainPage = new NavigationPage(new TabbedPage());
}

In Tabbed Pagged we could set the child page of it as NavigationPage like following

<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
            xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
            xmlns:local="clr-namespace:xxx;assembly=xxx"
            x:Class="TabbedPageWithNavigationPage.MainPage">
    <NavigationPage Title="Page1" IconImageSource="xxx.png">
        <x:Arguments>
            <local:SchedulePage />
        </x:Arguments>
    </NavigationPage>
    <NavigationPage Title="Page2" IconImageSource="xxx.png">
        <x:Arguments>
            <local:SchedulePage />
        </x:Arguments>
    </NavigationPage>
</TabbedPage>

And in Page1 or Page2 we could navigate to another ContentPage

await Navigation.PushAsync (new xxxPage ());

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM