如何在标签页之前添加内容页或查看页面

时间:2019-03-18 12:42:33

标签: xaml xamarin xamarin.forms tabbedpage

我想在TabbedPage之前添加页面/视图,我该怎么做?

<?xml version="1.0" encoding="utf-8" ?>
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"  
     xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
     xmlns:views="clr-namespace:TestProject.TabbedPages"  
     x:Class="TestProject.ItemPage"
     Title = "Home Page">
    <TabbedPage.Children>
    <views:AprovedLeaves Title="Approved leaves"/>
    <views:PendingLeaves Title="Pending leaves"/>
    <views:DeniedLeaves Title="Denied leaves"/>
    </TabbedPage.Children>
</TabbedPage>

上面的代码显示了这样的输出

enter image description here

但是制表符之前我需要一些空间。像这样

enter image description here

1 个答案:

答案 0 :(得分:1)

我建议您使用分段控制插件在Nuget上进行Plugin.Segmented的外观,并安装Plugin.SegmentedControl.NetStandard

在iOS上将其初始化如下:

 SegementedControlRenderer.Initialize();  

然后像这样在XAML中使用它

  <control:SegmentedControl x:Name="SegmentedControl" SelectedSegment="{Binding SegmentSelection}" TintColor="White" SelectedTextColor="BlueViolet" DisabledColor="Gray" Margin="8,8,8,8">  
        <control:SegmentedControl.Children>  
            <control:SegmentedControlOption Text="Item 1" />  
            <control:SegmentedControlOption Text="Item 2" />  
            <control:SegmentedControlOption Text="Item 3" />  
            <control:SegmentedControlOption Text="Item 4" />  
        </control:SegmentedControl.Children>  
    </control:SegmentedControl>  

C# corner blog

上有逐步指南

如有查询,请随时还原