在TabbedPage栏中添加/删除选项卡,并以编程方式更改app:tabMode

时间:2018-11-18 16:17:09

标签: c# xaml xamarin

在Xamarin中,我有一个TabbedPage,有时应该显示它,有时应该不显示。

<ContentPage x:Name="tab_Voeding5" IsEnabled="False">
    <StackLayout>
        <Label Text="Voeding pagina 5"
            VerticalOptions="CenterAndExpand" 
            HorizontalOptions="CenterAndExpand" />
    </StackLayout>
</ContentPage>

我尝试默认禁用它,并启用它:

if(Application.Current.Properties["txt_voeding5"].ToString() != "")
{
    tab_Voeding5.IsEnabled = true;
    tab_Voeding5.Title = Application.Current.Properties["txt_voeding5"].ToString();
}

但是,这仅禁用和启用导航栏中的选项卡式页面标题,但我希望将其完全删除/添加。我该怎么做?

此外,在Tabbar.axml中,我只希望A页上的app:tabMode="scrollable"。我希望它像app:tabMode="fixed"一样是默认值。如何以编程方式在页面的CS文件中更改app:tabMode

编辑:

Xaml文件

<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
         x:Class="TimeToSport.Views.VoedingPage"
         Title="Voeding">

<!-- Voeding 1 -->
<ContentPage x:Name="tab_Voeding1">
    <StackLayout>
        <Label Text="Voeding pagina 1"
            VerticalOptions="CenterAndExpand" 
            HorizontalOptions="CenterAndExpand" />
    </StackLayout>
</ContentPage>

<!-- Voeding 2 -->
<ContentPage x:Name="tab_Voeding2">
    <StackLayout>
        <Label Text="Voeding pagina 2"
            VerticalOptions="CenterAndExpand" 
            HorizontalOptions="CenterAndExpand" />
    </StackLayout>
</ContentPage>

<!-- Voeding 3 -->
<ContentPage x:Name="tab_Voeding3">
    <StackLayout>
        <Label Text="Voeding pagina 3"
            VerticalOptions="CenterAndExpand" 
            HorizontalOptions="CenterAndExpand" />
    </StackLayout>
</ContentPage>

<!-- Voeding 4 -->
<ContentPage x:Name="tab_Voeding4">
    <StackLayout>
        <Label Text="Voeding pagina 4"
            VerticalOptions="CenterAndExpand" 
            HorizontalOptions="CenterAndExpand" />
    </StackLayout>
</ContentPage>

<!-- Voeding 5 -->
<ContentPage x:Name="tab_Voeding5" IsEnabled="False">
    <StackLayout>
        <Label Text="Voeding pagina 5"
            VerticalOptions="CenterAndExpand" 
            HorizontalOptions="CenterAndExpand" />
    </StackLayout>
</ContentPage>
</TabbedPage>

0 个答案:

没有答案