microsoft / microsoft/microsoft-ui-xaml

TreeViewItem.IsExpanded in WindowsAppSDK 1.6/1.7/1.8 behaves inconsistently when repopulating the TreeView

Open
#10,309 6 comments 0 reactions 0 assignees View on GitHub
area-TreeView bug Regression team-Controls
Dominant language
C++
Stars
8.4k
Forks
942
Avg merge
2d 7h
Merged PRs (30d)
105

Description

### Describe the bug

When using TreeView's item template and setting TreeViewItem.IsExpanded to True in XAML, repopulating (clearing item and then adding new items) the tree a few times collapses all items.
When binding TreeViewItem.IsExpanded to a read-only property set to True, repopulating the tree randomly collapses/expands the items.
1.5 doesn't have this issue.

### Steps to reproduce the bug

A project that demonstrates the bug: https://github.com/usakgb/WinUITreeViewBug
1. Clone and run the project.
2. Click Repopulate button a few times.

### Expected behavior

All items to be expanded at all times.

### Screenshots

![Image](https://github.com/user-attachments/assets/3654fbae-3135-4557-a6ed-0d671be27bcf)

### NuGet package version

Windows App SDK 1.6.3: 1.6.241114003

### Packaging type

Packaged (MSIX)

### Windows version

Windows 11 version 22H2 (22621, 2022 Update)

### IDE

Visual Studio 2022

### Additional context

_No response_

Contributor guide

Open the contributing guide

Research direction

Clone the linked WinUITreeViewBug project and run it with Windows App SDK 1.6.3 on Windows 11. Click Repopulate repeatedly while observing TreeViewItem.IsExpanded, then compare the behavior with Windows App SDK 1.5. Done means identifying and fixing the regression so repopulating consistently leaves all items expanded, including the XAML and read-only binding cases.

Written by the indexing model from the issue text.

Assessment

Domain
desktop
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.