You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Skia] ListView: calling ScrollIntoView from SelectionChanged before the first layout pass permanently breaks virtualization (items above the target never render, later containers appear out of order) #24332
If a ListView gets a fresh ItemsSource and a programmatic SelectedItem in the same beat (in our app both come from x:Bind when the view model populates), and the SelectionChanged handler calls ScrollIntoView on the selected item, the panel ends up in a broken state when the scroll happens before the list has done its first layout over the new source:
All items above the selected one are simply missing. The list renders starting at the selected item as if it were the first one.
The missing items never get materialized by scrolling. Selecting one of them programmatically afterwards (e.g. a "previous item" button) generates its container, but appends it to the bottom of the list instead of its correct position.
Expected behavior 🎯
The full list renders and is scrolled to the selected item. Worst case, if scrolling this early isn't supported, the scroll should just not happen - the list shouldn't be permanently corrupted with no exception.
How to reproduce it (as minimally and precisely as possible) 🔬
Run the desktop head. The list starts at "Item 51" - items 1-50 are gone and can't be scrolled to.
Click "Select previous". "Item 50" appears at the bottom of the list, below "Item 100", selected.
Workaround 🛠️
Deferring the scroll by one dispatcher tick:
privatevoidOnSelectionChanged(objectsender,SelectionChangedEventArgse){if(List.SelectedItemis not null){DispatcherQueue.TryEnqueue(()=>{if(List.SelectedItemis{}selected)List.ScrollIntoView(selected);});}}
Renderer 🎨
Skia
Native
Affected platforms 📱💻🖥️
All platforms 🌍
Uno.Sdk version (and other relevant versions) 📦
6.7.18 and 6.7.0-dev.165
IDE version 🧑💻
No response
Anything else we need to know? 💬
Looks like the virtualization window gets seeded at the target index when the scroll request arrives before the panel has laid out the new source, and the leading range is never backfilled after that - which would explain both symptoms (missing leading items, and out-of-order container placement when one of them is materialized later).
Activity