简体   繁体   English

我们可以在xamarin表单的标签页上添加内容吗?

[英]Can We add content Above tabbed page in xamarin forms?

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 我想在xamarin表单的标签页上面添加一些标签和图像,所以当我滑到另一个标签页时,标签页上面的内容将保持不变这里是设计 在此输入图像描述

can i achieve this because i cant find any reference to do that ? 我可以实现这一点,因为我找不到任何参考吗?

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 演示代码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>


Demo Code cs file 演示代码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;
}

One of the ways is to create a control template, add the top section in any layout and insert the tab page in content presenter. 其中一种方法是创建控件模板,在任何布局中添加顶部部分,并在内容呈现器中插入选项卡页面。

https://developer.xamarin.com/guides/xamarin-forms/application-fundamentals/templates/control-templates/creating/ https://developer.xamarin.com/guides/xamarin-forms/application-fundamentals/templates/control-templates/creating/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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