Xaml 表单:如何在整个应用程序中获得选项卡式页面
我需要在整个应用程序中使用TabbedPage。在第一页中,选项卡显示良好。当我从Tab1开始第二页时,它隐藏了所有选项卡。我怎么能在应用程序上都有标签呢 MainPage.xamlXaml 表单:如何在整个应用程序中获得选项卡式页面,xaml,xamarin,xamarin.forms,Xaml,Xamarin,Xamarin.forms,我需要在整个应用程序中使用TabbedPage。在第一页中,选项卡显示良好。当我从Tab1开始第二页时,它隐藏了所有选项卡。我怎么能在应用程序上都有标签呢 MainPage.xaml <?xml version="1.0" encoding="utf-8" ?> <TabbedPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.c
<?xml version="1.0" encoding="utf-8" ?>
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="TabbedApp.MainPage"
xmlns:local="clr-namespace:TabbedApp">
<local:DairyTabs></local:DairyTabs>
<ContentPage Title="Tab 2">
<StackLayout>
<Label Text="Tab 2"
HorizontalTextAlignment="Center"
HorizontalOptions="FillAndExpand"
Margin="5" />
</StackLayout>
</ContentPage>
</TabbedPage>
尝试使用:
Navigation.pushAsync新建第2页
而不是:
Navigation.PushModalAsyncnew第2页
我需要在整个应用程序中使用TabbedPage
必须将NavigationPage作为子页添加到选项卡页中,才能打开选项卡内的页面
因此,在Xaml中,您可以在TabbedPage中有一个NavigationPage
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="TabbedApp.MainPage"
xmlns:local="clr-namespace:TabbedApp">
<local:PageA/>
<NavigationPage Title="Your Title">
<x:Arguments>
<local:MyPage />
</x:Arguments>
</NavigationPage>
</TabbedPage>
因此,可以从第二个页面执行导航,这是NavigationPage的一个实例,如下所示
async void OnSomeButtonClicked (object sender, EventArgs e)
{
await Navigation.PushAsync (new Page2());
}
更多信息请参见这里是PageA和MyPage之间的区别。PageA在NavigationPage之外,MyPage在里面。这里,PageA是您的第一个选项卡,它是一个ContentPage,第二个选项卡是MyPage,它是一个NavigationPage,允许您在此选项卡内打开另一个页面OK,当我们转到第二个选项卡MyPage时,它只是开始在顶部显示Navigationbar。除了不更改任何内容之外,这里的MyPage也必须是ContentPage
public class MainPageCS : TabbedPage{
public MainPageCS ()
{
var navigationPage = new NavigationPage (new MyPage ());
navigationPage.Title = "Your title";
Children.Add (new PageA ());
Children.Add (navigationPage);
}
}
async void OnSomeButtonClicked (object sender, EventArgs e)
{
await Navigation.PushAsync (new Page2());
}