Checkbox in DataGridTemplateColumn : Clicking on checkbox generates ghost checkbox #4959
Open
1 of 14 tasks
Labels
bug 🐛
An unexpected issue that highlights incorrect behavior
DataGrid 🔠
Issues on DataGrid control
needs attention 👋
needs triage 🔍
Describe the bug
I created a UserControl that contains a DataGrid, which contains one DataGridTemplateColumn, which contains a checkbox.
The IsChecked of that checkbox is binded with an ObservableProperty of a POCO class.
When clicking randomly on the checkboxes, and setting a breakpoint into the event OnChecked, we can see that we pass several times into it, and the datacontext linked to the checkbox is sometimes null. I set another breakpoint in the code generated by my UserControl (.g.cs file) into the Connect function, and I can observe that the thread pass several times into the code of the checkbox creation.
The fact the checkbox is binded to an Observable Property makes the bug happen (with a regular property, no bug). If I delete the ObservableProperty tag on the property, and I raise a OnPropertyChanged event in the setter, I also observe the bug.
Regression
No response
Reproducible in sample app?
Steps to reproduce
Expected behavior
I can't explain why the fact I binded the IsChecked property of my Checkbox to an ObservableProperty in my model triggers the creation of ghost checkbox (with null datacontext).
I found a workaround for my code, but thouht it was worth it reporting this behavior.
Screenshots
No response
Windows Build Number
Other Windows Build number
Windows 11 22H2
App minimum and target SDK version
Other SDK version
No response
Visual Studio Version
2022
Visual Studio Build Number
No response
Device form factor
No response
Nuget packages
CommunityToolkit.WinUI.UI.Controls 7.1.2
CommunityToolkit.Mvvm 8.2.2
Additional context
No response
Help us help you
No.
The text was updated successfully, but these errors were encountered: