【问题标题】:How to hide a tab from a TabbedPage when using a condition (xamarin forms)使用条件时如何从 TabbedPage 隐藏选项卡(xamarin 表单)
【发布时间】:2020-05-21 20:07:56
【问题描述】:

我有以下问题,我有一个系统,当进入时有一个带有 TabbedPage 的 xaml 使用不同的内容页面(例如选项卡),但是当满足某个条件时,我需要其中一个为用户隐藏。

我该怎么做?

干杯

【问题讨论】:

  • 需要动态显示/隐藏,还是只需要隐藏就不再显示?
  • 当app登录时,系统会进行tab的隐藏/显示,如果下一个用户不同且有其他权限则再次提问
  • @FelipeParraSoto 您好,如果回答对您有帮助并解决了问题,记得有空时标记一下。

标签: c# visual-studio xamarin xamarin.forms xamarin-studio


【解决方案1】:

在页面的构造函数中只检查添加子页面时。我不知道是否有一种简单的方法可以在 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());
    }

  }
}

【讨论】:

    猜你喜欢
    • 2022-01-08
    • 2018-07-17
    • 2019-05-16
    • 1970-01-01
    • 2020-12-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多