Skip to content
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

Fix issue #11006 by correcting SelectionChanged event to be fired AFTER (not before) raising Prop… #13503

Merged
merged 3 commits into from
Nov 20, 2023

Conversation

lnxon
Copy link
Contributor

@lnxon lnxon commented Nov 6, 2023

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".

2023-11-06 130710

@Cpasjuste
Copy link

Hi,

I didn't test this PR but I can confirm the bug, I hope this will be merged soon!

@lnxon
Copy link
Contributor Author

lnxon commented Nov 20, 2023

@Cpasjuste Me too, hope this can be merged soon...
@maxkatz6 Thank you for your consideration of this pull request, I just added the unit test to the PR!

@maxkatz6 maxkatz6 added this pull request to the merge queue Nov 20, 2023
Merged via the queue into AvaloniaUI:master with commit 40b73a6 Nov 20, 2023
6 checks passed
@maxkatz6 maxkatz6 added the backport-candidate-11.0.x Consider this PR for backporting to 11.0 branch label Nov 28, 2023
maxkatz6 pushed a commit that referenced this pull request Dec 5, 2023
…ER (not before) raising Prop… (#13503)

* fix selectedchanged event to be fired AFTER (not before) raising Property changed notification

* Unit test added
@maxkatz6 maxkatz6 added backported-11.0.x and removed backport-candidate-11.0.x Consider this PR for backporting to 11.0 branch labels Dec 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Get old selected value instead of new selected value from comboBox in MVVM application
3 participants