[英]Can We add content Above tabbed page in xamarin forms?
如果要在選項卡頁面上方添加標簽,則無法在選項卡頁面中添加標簽,您必須創建自己的選項卡頁面。
您可以根據您的選擇創建顯示/隱藏的布局創建選項卡設計,並點擊手勢到選項卡並管理布局的顯示/隱藏
演示代碼Xaml文件
<!--Tab Design-->
<StackLayout Orientation="Horizontal">
<Grid HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand"
ColumnSpacing="0"
RowSpacing="0"
Padding="0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
</Grid.ColumnDefinitions>
<!--Details Tab-->
<StackLayout Grid.Row="0"
Grid.Column="0"
Padding="7.5"
VerticalOptions="FillAndExpand">
<Button Clicked="Tab1Clicked" Text="Tab1">
</StackLayout>
<!-- Tab 2 -->
<StackLayout Grid.Row="0"
Grid.Column="2"
Padding="7.5"
VerticalOptions="FillAndExpand">
<Button Clicked="Tab2Clicked" Text="Tab2">
</StackLayout>
</Grid>
</StackLayout>
<!-- tab 1 container -->
<StackLayout x:Name="stkTab1">
</StackLayout>
<!-- tab 2 container -->
<StackLayout x:Name="stkTab2" IsVisible="false">
</StackLayout>
演示代碼cs文件
private void Tab1Clicked(object sender, EventArgs e)
{
stkTab1.IsVisible=true;
stkTab2.IsVisible=false;
}
private void Tab2Clicked(object sender, EventArgs e)
{
stkTab1.IsVisible=false;
stkTab2.IsVisible=true;
}
其中一種方法是創建控件模板,在任何布局中添加頂部部分,並在內容呈現器中插入選項卡頁面。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.