我们可以在 xamarin 形式的标签页上方添加内容吗? [英] Can We add content Above tabbed page in xamarin forms?
问题描述
我想在 xamarin 形式的选项卡页面上方添加一些标签和图像,因此当我滑动到另一个选项卡页面时,选项卡页面上方的内容将保持不变,这里是设计
I want to add some label and image above tabbed page in xamarin forms, so when i slide to another tabbed page the content above tabbed page will remain the same here is the design
我能做到这一点,因为我找不到任何参考来做到这一点吗?
can i achieve this because i cant find any reference to do that ?
推荐答案
如果要在标签页上方添加标签,则不能在标签页上方添加标签,您必须创建自己的标签页.
您可以创建根据您的选择显示/隐藏的布局创建选项卡设计和点击选项卡的手势并管理布局的显示/隐藏
演示代码 Xaml 文件
You can not add label above in tabbed page if you want to add label above tabbed page you have to crate your own tabbed page.
You can create a layout that show/hide based on your selection for your selection create tab design and tap gesture to tabs and manage show/hide of layouts
Demo Code Xaml file
<!--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;
}
这篇关于我们可以在 xamarin 形式的标签页上方添加内容吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!