Fix issue #11006 by correcting SelectionChanged event to be fired AFTER (not before) raising Prop… #13503
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix issue #11006 by correcting SelectionChanged event to be fired AFTER (not before) raising Property changed notification
What does the pull request do?
Fix issues reported in #11006 "Get old selected value instead of new selected value from comboBox in MVVM application" and
issue #92 of Avalonia.Xaml.Behaviors "EventTriggerBehavior not working as expected".
What is the current behavior?
When you use EventTriggerBehavior and InvokeCommandAction to capture SelectionChanged event, the event is fired before notify SelectedIndex property change, resulting in capturing old value remaining in the property; the desired behavior is to notify the SelectedIndex change first, and then, trigger SelectionChanged event, as so, the new selected index will be available just in the moment SelectionChanged event is fired.
What is the updated/expected behavior with this PR?
Combobox selectedindex value correctly reflected and available in the binded VM property when SelectionChanged event fires.
You can for example compile and run the test application created by dellbeat publicated in the issue #11006 to verify correct behavior (shown below by screenshot).
How was the solution implemented (if it's not obvious)?
The code block notifying property changes moved to the front of the code block issuing events (event.invoke()).
Checklist
Breaking changes
Obsoletions / Deprecations
Fixed issues
Fixes #11006
also fixes issue 92 of Avalonia.Xaml.Behaviors "EventTriggerBehavior not working as expected".