-
-
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
ListBox selection state not updating correctly #18048
Comments
You have a custom control here. Please test plain ListBox instead. |
Per your request, I have refactored it so that it is a plain |
I can see the issue but don't have an idea where exactly the root cause is. What I prefer if I have a "complex" selection is to implement |
Could you clarify please? |
Just add the interface to your viewmodel or any other class and bind this to ListBox.Selection |
Thanks! I will try that. Are there any examples of this binding anywhere? I can't find a single one. |
Describe the bug
When the user interacts with the ListBox to change the selection state of one item and needs that change to select or deselect another item in the ListBox, changes to the view model do not always propagate to the view. Selecting the item a second time does successfully propagate that change.
To Reproduce
Download and run the attached solution.
Details:
MainWindow:
Contains the ListBox item in question.
ViewModel:
A class
MainViewModel
, that contains anItems
property with each item having anIsSelected
property which it TwoWay bound to theListBoxItem
'sIsSelected
property.OptionItem:
Represents each item in the
ListBox
Expected behavior
When the user interacts with the ListBox to change the selection state of one item and needs that change to select or deselect another item in the ListBox, changes to the view model should always reflect the correctly updated items in the ListBox.
Avalonia version
11.2.3, 11.1.0, 11.0.10
OS
Windows 11 24H2
Additional context
Full solution to repro:
AvaloniaListBoxMultiselectToggle.zip
The text was updated successfully, but these errors were encountered: