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

ListBox AlwaysSelected issue when selected item is not visible during removal #16169

Open
jeromemanzano opened this issue Jun 29, 2024 · 0 comments
Labels

Comments

@jeromemanzano
Copy link

Describe the bug

When the ListBox.SelectionMode is set to AlwaysSelected and you attempt to remove the first selected ListBoxItem while it is not visible, the item that gets removed is actually the next ListBoxItem. As a result, the first ListBoxItem stays selected.

To Reproduce

  1. Set SelectionMode of ListBox to AlwaysSelected. First ListBoxItem should be selected when the app is running.
  2. Scroll to the bottom of ListBox (so first ListBoxItem is not visible)
  3. Remove first ListBoxItem
  4. Scroll back to the top of ListBox
  5. It will show that it's the second ListBoxItem that was removed instead of first, and first ListBoxItem is still selected.

Kapture 2024-06-29 at 21 01 27###

Expected behavior

When first ListBoxItem is removed, it should be removed in the ListBox, and the second ListBoxItem should be the new SelectedItem
Kapture 2024-06-29 at 20 56 26

Avalonia version

11.0.11

OS

macOS

Additional context

You can find the test code here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant