[使用条件时如何从TabbedPage中隐藏选项卡(Xamarin形式)

问题描述 投票:0回答:1

我有以下问题,我有一个系统,当输入带有TabbedPage的xaml时,使用了诸如选项卡之类的不同内容页面,但是当满足特定条件时,我需要为用户隐藏其中的一个。

我该怎么做?

欢呼声

c# visual-studio xamarin xamarin.forms xamarin-studio
1个回答
0
投票
在页面的构造函数中,仅在添加子页面时检查。我不知道在XAML中是否有一种简单的方法可以执行相同的操作

public class MyPage : TabbedPage { public MyPage() { this.Children.Add(new Page1()); this.Children.Add(new Page2()); if (some conditional check based on user) { this.Children.Add(new Page3()); } } }

© www.soinside.com 2019 - 2024. All rights reserved.