UraniumUI
UraniumUI copied to clipboard
Tabview handle visibility for a tabitem
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?
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>
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
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
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. :)
@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?
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;