Description
Describe the bug
Setting PivotItem.Visiblity to Collapsed does not remove a PivotItem, it only collapses the Content.
A common scenario when using a Pivot for tab navigation requires sometimes hiding a tab. This was always possible in other controls like in WPF's TabControl which Pivot was supposed to replace. However, in UWP, setting PivotItem.Visiblity=Collapsed will hide the Content but the PivotItem and its header are still shown within the Pivot and appear in the VisualTree. This means there is no way to hide a pivot's 'tab'.
This is a very old issue that has been reported years ago on user voice (before it was deleted) and is on multiple forums. It's something that should be simple to address in the platform but is complex to work-around in applications.
Steps to reproduce the bug
- Add a Pivot in XAML with at least 1 PivotItem
- Set a PivotItem's Visiblity=Collapsed
- The PivotItem Header is still visible in the Pivot
Expected behavior
If the PivotItem itself is Collapsed the Header and the entire PivotItem should be removed from the VisualTree. This also means keyboard navigation is no longer possible.
Screenshots
Version Info
NuGet package version:
Microsoft.UI.Xaml 2.4.0
Windows 10 version | Saw the problem? |
---|---|
May 2020 Update (19041) | Yes |
Device form factor | Saw the problem? |
---|---|
Desktop | Yes |
Xbox | |
Surface Hub | |
IoT |
Additional context
This will require WinUI 3.0 to be fixed. I will fix it myself if it comes to it -- this has been a thorn for years.