-
-
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
Scrolling a ListBox with virtualization messes up the keyboard focus #9269
Comments
I'm going to create a pull request to fix this |
Sorry, I got lost, we need an expert here. |
Not sure how possible it is. |
Also, if ItemsRepeater and DataGrid have the same problem (probably have) |
It works in WPF. |
Checking the visual children of a ListBox using the debugger shows that WPF keeps the focused element alive in the visual tree, and does not reuse it for displaying other items. |
I cannot reproduce this for ItemsRepeater and DataGrid. |
Using ItemsRepeater in ListBox may be a possible solution, see #2594 |
Describe the bug
Scrolling a ListBox with VirtualizationMode=Simple changes the keyboard focus to another item when the focused item gets out of view. The issue does not occur when VirtualizationMode is None.
To Reproduce
Steps to reproduce the behavior:
public List<int> Items { get; set; } = new(Enumerable.Range(0, 1000));
<ListBox Items="{Binding Items}" VirtualizationMode="Simple"/>
The issue is also visible in the VirtualizationDemo sample.
Expected behavior
The keyboard focus should not change while scrolling.
The virtualization code should not recycle the element having the keyboard focus.
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: