TreeView does not clear nodes state after updating ItemsSource #7044
Labels
area-TreeView
bug
Something isn't working
product-winui3
WinUI 3 issues
team-Controls
Issue for the Controls team
Describe the bug
After updating
TreeView.ItemsSource
property TreeViewNode(s)/TreeViewItem(s) are not updated properly. It seems like TreeView is reusing previously created TreeViewNode(s)/TreeViewItem(s) without properly resetting their state. Below you can find example showing problem withStyle
andIsExpanded
properties ofTreeViewItem
. The same will happen withHasUnrealizedChildren
property of TreeViewNode. The issue exists if you updateItemsSource
in code behind or using binding.Steps to reproduce the bug
In VisualStudio 2022 (17.1.3) create new project -
Blank App, Packaged (WinUI 3 in Desktop)
.Add code to MainWindow.xaml file
Expected behavior
After updating
ItemsSource
property existingRootNodes
should be cleared and new nodes should be created for new items.Screenshots
NuGet package version
WinUI 3 - Windows App SDK 1.0.3
Windows app type
Device form factor
Desktop
Windows version
Windows 10 (21H1): Build 19043
Additional context
Earlier I experienced strange behavior of
SelectedItems
property. After changingItemsSource
or even setting it tonull
theSelectedItems
wasn't empty.The text was updated successfully, but these errors were encountered: