我有标签页,在其中我有3个标签,我需要enabled=false第二和第三个标签。当我完成第一页时,我需要像表单向导一样工作,然后第二个选项卡应该是enabled=true,我已经尝试过像下面这样的代码,但它不起作用。
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Name="maintab"
x:Class="OnlineKIHStore.Views.CheckOuts"
BarBackgroundColor="#2F3C51"
Title="Checkout"
BarTextColor="White">
<ContentPage x:Name="first" Title="Login/Register" Icon="user" IsEnabled="True">
<StackLayout>
</ContentPage>
<ContentPage x:Name="second" Title="SHIPPING" Icon="shipping" IsEnabled="False">
</ContentPage>
<ContentPage x:Name="third" Title="Payment" Icon="payment" IsEnabled="False">
</ContentPage>
</TabbedPage>发布于 2018-11-05 21:57:32
一种方法--一开始不要加载您想要的选项卡。完成第1页后,插入所需的选项卡。
这是我的示例,根据您的代码
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Name="maintab"
x:Class="OnlineKIHStore.Views.CheckOuts"
BarBackgroundColor="#2F3C51"
Title="Checkout"
BarTextColor="White">
<TabbedPage.Children>
<firstPage Title="Login/Register" Icon="user"/>
<thirdPage Title="Payment" Icon="payment"/>
</TabbedPage.Children>
在.CS文件中
public CheckOuts
{
InitializeComponent();
if(check_finished_pageone)
{
Children.Insert(2, new SecondPage { Title = "SHIPPING", Icon = "shipping" });
}}完成page1后,重新加载该表页。因此,现在您的第二个页面将添加新的选项卡栏。
还有一个方法是,一旦单击了第2页,就可以导航到第1页,提示用户完成第1页。
e<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Name="maintab"
x:Class="OnlineKIHStore.Views.CheckOuts"
BarBackgroundColor="#2F3C51"
Title="Checkout"
CurrentPageChanged="TabbedPage_CurrentPageChanged"
BarTextColor="White">.CS文件
private async void TabbedPage_CurrentPageChanged(object sender, EventArgs e){
var i = this.Children.IndexOf(this.CurrentPage);
if (i == 2)
{
await App.Current.MainPage.DisplayAlert("Error", "You have to finish the page one before navigating this page", "Ok"))
this.CurrentPage = this.Children[0];
}}此方法允许您单击第二个选项卡,但它将再次直接到第1页。
https://stackoverflow.com/questions/53151636
复制相似问题