Skip to content

Setting PivotItem.Visiblity to Collapsed Does not Remove It from Pivot #2952

Closed as not planned
@robloo

Description

@robloo

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

  1. Add a Pivot in XAML with at least 1 PivotItem
  2. Set a PivotItem's Visiblity=Collapsed
  3. 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

image

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-PivotbugSomething isn't workingneeds-triageIssue needs to be triaged by the area ownersneeds-winui-3Indicates that feature can only be done in WinUI 3.0 or beyond. (needs winui 3)team-ControlsIssue for the Controls team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions