Skip to content

Proposal: Allow scrolling by index in ListView and GridView #5069

@huoyaoyuan

Description

@huoyaoyuan

Proposal: Allow scrolling by index in ListView and GridView

Summary

public abstract class ListViewBase
{
    // existing
    public void ScrollIntoView(object item);
    public void ScrollIntoView(object item, ScrollIntoViewAlignment alignment);

    // new
+    public void ScrollIntoView(int index);
+    public void ScrollIntoView(int index, ScrollIntoViewAlignment alignment);
}

Rationale

ScrollIntoView is useful, but it doesn't work well with range-based virtualization (IItemsRangeInfo). Say I have a list with 100K~1M items, and a jump box to jump at arbitrary position. The current object-based ScrollIntoView requires creating the corresponding item before scrolling. With index-based scrolling, the item can be created naturally when scrolled to using IItemsRangeInfo.
It may also improve the performance, since getting index from object is typically way slower than the opposite, and the index is required to perform scrolling.

Scope

Capability Priority
ListViewBase.ScrollIntoView can take index. Must

Important Notes

Open Questions

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-ListsListView, GridView, ListBox, etcfeature proposalNew feature proposalneeds-winui-3Indicates that feature can only be done in WinUI 3.0 or beyond. (needs winui 3)team-ControlsIssue for the Controls team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions