The Windows Community Toolkit is a collection of helpers, extensions, and custom controls. It simplifies and demonstrates common developer tasks building .NET apps with UWP and the Windows App SDK / WinUI 3 for Windows 10 and Windows 11. The toolkit is part of the .NET Foundation.
We are using the FrameworkElementExtension.Ancestor for the ComboBox.ItemsSource binding. When we unload the ComboBox, the binding remains active, causing the SelectionChanged event to trigger after the Unloaded event. As a result, the SelectedItem is not maintained in our application. This issue specifically occurs when using the FrameworkElementExtension from the CommunityToolKit.WinUI.Extensions package.
Replication Procedure
1.Run the sample
2.Click the drop down of the FrameworkElementExtension Binding combo box.
3.Select Personnel.
4.Click Reset Control button.
Expected behavior
Expected behavior - TextBox Text needs to be remains the same.
Observed behavior - TextBox Text changes to null.
CommunityToolKit.WinUI.Extensions - version - 8.0.240109
CommunityToolKit.Mvvm - version - 8.2.2
Microsoft.Windows.SDK.BuildTools - version - 10.0.22621.765
MicrosoftWindowsSDKApp - version - 1.5.240607001
Additional context
No response
Help us help you
Yes, I'd like to be assigned to work on this item.
Describe the bug
We are using the
FrameworkElementExtension.Ancestor
for theComboBox.ItemsSource
binding. When we unload the ComboBox, the binding remains active, causing the SelectionChanged event to trigger after the Unloaded event. As a result, the SelectedItem is not maintained in our application. This issue specifically occurs when using the FrameworkElementExtension from the CommunityToolKit.WinUI.Extensions package.Sample - ComboBox_BindingIssue.zip
Unnecessary calls for SelectionChanged event after Unloaded event triggers - UnnecessaryCallForSelectionChanged.zip
Regression
No response
Reproducible in sample app?
Steps to reproduce
Expected behavior
Expected behavior - TextBox Text needs to be remains the same. Observed behavior - TextBox Text changes to null.
Screenshots
https://github.com/CommunityToolkit/WindowsCommunityToolkit/assets/124787498/31d24d2f-c438-4715-bac2-db71d9b2697b
Windows Build Number
Other Windows Build number
No response
App minimum and target SDK version
Other SDK version
No response
Visual Studio Version
2022
Visual Studio Build Number
17.10.1
Device form factor
Desktop
Nuget packages
CommunityToolKit.WinUI.Extensions - version - 8.0.240109 CommunityToolKit.Mvvm - version - 8.2.2 Microsoft.Windows.SDK.BuildTools - version - 10.0.22621.765 MicrosoftWindowsSDKApp - version - 1.5.240607001
Additional context
No response
Help us help you
Yes, I'd like to be assigned to work on this item.