Search code examples
c#visual-studioxamarinxamarin.formsxamarin-studio

How to hide a tab from a TabbedPage when using a condition (xamarin forms)


I have the following problem, I have a system that when entering has an xaml with TabbedPage using different content pages such as tabs, but when a certain condition is met I need one of them to hide for the user.

How can I do that?

Cheers


Solution

  • in the constructor of the page just check when adding the child pages. I don't know if there is an easy way to do the same thing in 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());
        }
    
      }
    }