microsoft / microsoft/microsoft-ui-xaml
ListView does not clear/recycle containers after clearing items inside ICollectionView.CollectionGroups
- Dominant language
- C++
- Stars
- 8.4k
- Forks
- 942
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 105
Description
### Describe the bug
When using a custom implementation of ICollectionView (with grouping via CollectionGroups) in a `ListView` that uses `ItemsStackPanel`, clearing items inside each group removes the data but stale UI containers remain visible. `ItemsStackPanel` appears to not clear/recycle containers correctly after grouped items are cleared. The custom implementation code used can be found here [GroupingTest/CustomImplementaion](https://github.com/w-ahmad/GroupingTest/tree/master/GroupingTest/CustomImplementation).
### Why is this important?
I'm trying to implement collapsible row grouping in [WinUI.TableView](https://github.com/w-ahmad/WinUI.TableView) by using `ICollectionView.CollectionGroups` with my own implementation and this bug blocks a core scenario needed for this feature.
### Steps to reproduce the bug
[GroupingTest.zip](https://github.com/user-attachments/files/27454011/GroupingTest.zip)
1. Run the repro app that is attached or clone it here [GroupingTest](https://github.com/w-ahmad/GroupingTest).
2. The app displays grouped data in a ListView.
3. Click the "Clear Group Items" button that clears items one by one for each group.
### Actual behavior
The `ListView` shows the containers for the items that are no longer in a CollectionGroup.
### Expected behavior
`ListView` should clear containers when the items are no longer in a CollectionGroup.
### Screenshots
https://github.com/user-attachments/assets/79a06665-e093-4902-bbad-9eca8b905fbd
### NuGet package version
Microsoft.WindowsAppSDK 2.0.1
### Windows version
Windows 11 (24H2): Build 26100
### Additional context
This issue only occurs when using `ItemStackPanel` as the ItemsPanel, whereas the `VirtualizingStackPanel` works fine but has some performance drawbacks.
Contributor guide
Research direction
Start with the attached GroupingTest repro and its CustomImplementation example, then compare the grouped clearing behavior of ItemsStackPanel with VirtualizingStackPanel. Trace what happens when items are cleared from each CollectionGroup; done means containers for removed items are no longer visible while grouped items continue to display correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- desktop, frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100