Skip to content

ListView scrolls to the selected item even when it doesn't have focus #25833

Closed

Description

@Xiaoy312

Current behavior 🐛

Every selection change in a ListView or GridView (including the inner list of a TreeView) scrolls the newly selected item into view, whether or not the list has focus. Setting SelectedItem or SelectedIndex from code on a list that doesn't have focus scrolls the list to that item, even far off-screen.

In Multiple selection mode it goes the other way: the first selection isn't brought into view even when the list has focus.

Expected behavior 🎯

Match WinUI (Selector::SetFocusedItem, measured on Windows App SDK 1.7):

  • A list scrolls a new selection into view only while it has focus, by the minimum distance. Clicking a row focuses it, so a row cut off at the edge still scrolls just enough to be fully visible.
  • A list without focus, or one that lost focus, never scrolls when its selection is changed from code.
  • In Multiple mode, only the first selection (from nothing selected) is brought into view.

How to reproduce it (as minimally and precisely as possible) 🔬

  1. <ListView x:Name="list" Height="200" /> with 100 items, plus a Button that runs list.SelectedIndex = 50;.
  2. Without clicking into the list first, click the button.
  3. Uno: the list scrolls to item 50. WinUI: the list stays at the top.

Workaround 🛠️

Save ScrollViewer.VerticalOffset before changing the selection and restore it with ChangeView afterwards.

Affected platforms 📱💻🖥️

All platforms 🌍

Uno.Sdk version (and other relevant versions) 📦

Current master.

IDE version 🧑‍💻

N/A

Anything else we need to know? 💬

Uno already has WinUI's code path ported, with the scroll commented out (Selector.SetFocusedItem); the unconditional scroll comes from Selector.ScrollSelectionIntoView.

Activity

  1. added
    kind/bug
    triage/untriaged
    on Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugtriage/untriaged

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions