[英]How to set first tab after loading page?
I`m using toolkit to make tabs on my page.我正在使用工具包在我的页面上制作标签。 I want to set special tab (in this context it is third tab) as showing tab after loading my tabPage.我想在加载我的 tabPage 后将特殊选项卡(在这种情况下是第三个选项卡)设置为显示选项卡。 How can i do it?我该怎么做? Thanks谢谢
<xct:TabView IsTabTransitionEnabled="False" IsSwipeEnabled="False" x:Name="TabView" Style="{StaticResource CustomTabStyle}">
<xct:TabView.TabStripBackgroundView >
<BoxView BackgroundColor="White" HeightRequest="0" WidthRequest="30" CornerRadius="0,0,0,0" />
</xct:TabView.TabStripBackgroundView>
<xct:TabViewItem
Text="text1"
Icon="Logo.png"
x:Name="Tab1"
ControlTemplate="{StaticResource TabItemTemplate}">
<view:Page1/>
</xct:TabViewItem>
<xct:TabViewItem
x:Name="Tab2"
Text="text2"
ControlTemplate="{StaticResource FabTabItemTemplate}"
<view:Page2 />
</xct:TabViewItem>
<xct:TabViewItem
x:Name="Tab3"
Text="text3"
ControlTemplate="{StaticResource TabItemTemplate}" >
<view:Page3/>
</xct:TabViewItem>
</xct:TabView>
See https://docs.microsoft.com/en-us/xamarin/community-toolkit/views/tabview请参阅https://docs.microsoft.com/en-us/xamarin/community-toolkit/views/tabview
TabView has a SelectedIndex property which you can use to set the selected tab. TabView 有一个 SelectedIndex 属性,您可以使用它来设置选定的选项卡。
You could just set SelectedIndex in your code behind like:您可以在后面的代码中设置 SelectedIndex,例如:
public YourPage()
{
InitializeComponent();
TabView.SelectedIndex = 2; //TabView is the name you define in your xaml x:Name = "TabView"
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.