-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IsCheckedChanged fires before PropertyChanged #18053
Comments
I don't think this is possible without something being wrong at a deeper level.
IsCheckedChanged is fired FROM the property changed notification itself. The base OnPropertyChanged is called first as well. In fact, within an event handler, it's designed to be able to read the current IsChecked property value. |
Tried in simple repro without tasks etc. Something with animation? Difference after First breakpoint IsCheckedChanged stacktrace:
Second got PropertyChanged:
|
Or scheduling of the property change notification. Maybe the event is scheduled to fire after the internal override is called. I know there is change notification grouping, etc. for performance. The easiest would be simply to schedule OnIsCheckedChanged on the dispatcher too. But I think this is a general issue that should be addressed deeper in the framework. |
Also DevTools could give a hint, see Events tab |
I'm not terribly familiar with the devtools. What should I be looking out for, specifically? |
Describe the bug
ToggleButton's IsCheckedChanged event fires before PropertyChanged. This has the side effect of causing commands that fire on this event to use the incorrect boolean value.
To Reproduce
This repository contains a minimal example of this behavior
https://github.com/ALDamico/IsCheckedChangedBug
Expected behavior
I'd expect the IsCheckedChanged event to fire after PropertyChanged fires.
Avalonia version
11.2.3
OS
Windows
Additional context
Possible workaround
Trigger the command on PropertyChanged, if the ViewModel has few properties.
The text was updated successfully, but these errors were encountered: