UraniumUI icon indicating copy to clipboard operation
UraniumUI copied to clipboard

Tabview handle visibility for a tabitem

Open akhilvswoodplc opened this issue 1 year ago • 6 comments

Is it possible to handle visibility for a tabitem. For example I have 5 tabs with different content and after some action I need to set one tab visibility to false. Is this possible?

akhilvswoodplc avatar Jan 22 '24 13:01 akhilvswoodplc

It might be a good feature for TabItem.

Currently you can achieve it by defining custom Header Template:

  <material:TabItem Title="Tab Three">
      <material:TabItem.HeaderTemplate>
          <DataTemplate>
              <Button
                  Text="{Binding Title}"
                  Command="{Binding Command}"
                  IsVisible="YOUR_VISIBLE_LOGIC">
                  
              </Button>
          </DataTemplate>
      </material:TabItem.HeaderTemplate>
          <material:TabItem.ContentTemplate>
              <DataTemplate>
                  <!-- Content -->
              </DataTemplate>
          </material:TabItem.ContentTemplate>
      </material:TabItem>

enisn avatar Jan 22 '24 14:01 enisn

It might be a good feature for TabItem.

Currently you can achieve it by defining custom Header Template:

  <material:TabItem Title="Tab Three">
      <material:TabItem.HeaderTemplate>
          <DataTemplate>
              <Button
                  Text="{Binding Title}"
                  Command="{Binding Command}"
                  IsVisible="YOUR_VISIBLE_LOGIC">
                  
              </Button>
          </DataTemplate>
      </material:TabItem.HeaderTemplate>
          <material:TabItem.ContentTemplate>
              <DataTemplate>
                  <!-- Content -->
              </DataTemplate>
          </material:TabItem.ContentTemplate>
      </material:TabItem>

@enisn This will still consume the space utilized by the hidden tab

akhilvswoodplc avatar Jan 23 '24 06:01 akhilvswoodplc

You're right,

I'll implement this feature in the next version

I can't suggest any better workaround except adding & removing tab with code

enisn avatar Jan 23 '24 06:01 enisn

You're right,

I'll implement this feature in the next version

I can't suggest any better workaround except adding & removing tab with code

Yes. Removing tabs from code behind works for now. :)

akhilvswoodplc avatar Jan 23 '24 06:01 akhilvswoodplc

@enisn I see the new version got this issue fix by adding IsVisible property. But still I could see the space consumed by hidden tab. Is this expected?

akhilvswoodplc avatar Mar 21 '24 09:03 akhilvswoodplc

Is there a way to add tabs from the code behind? Like akhilvswoodplc said, you can still see the space when it's not visible. I tried removing in the code behind which works, but when trying to re-add a tab, it also just adds a blank space.

In the first option, I tried both insert lines and they just add a blank space. The second option does the same. Binding IsVisible in the XAML did not seem to do anything.

// option 1
if (message.Value)
{
    if (TabItems[2].Title != EvaluationsTab.Title)
    {
        TabItems.Insert(2, EvaluationsTab);
        // TabItems.Insert(2, new UraniumUI.Material.Controls.TabItem() { Title = "Test" });
    }
}
else
    TabItems.RemoveAt(2);

// option 2
if (message.Value)
    TabItems[2].IsVisible = true;
else
    TabItems[2].IsVisible = false;

codychaplin avatar May 24 '24 18:05 codychaplin