dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.22k stars 1.75k forks source link

CollectionView: ScrollTo item when setting SelectedItem #12920

Open JkPersson opened 1 year ago

JkPersson commented 1 year ago

Description

Setting a selected item from the view model, I would expect the scroll view to scroll to the selected item. This is not the case. Therefore I suggest adding a new property 'SelectedItemScroll', which could be set to 'NoScroll' or 'ScrollToItem'.

I would prefer the latter to be default, but since the first is similar to current functionality, it would probably be the most natural choice.

Public API Changes

<CollectionView Grid.Row="1"
    ItemsSource="{Binding Locations}"
    SelectedItem="{Binding SelectedLocation}"
    SelectionMode="Single"
    SelectedItemScroll="ScrollToItem">

<CollectionView />

Intended Use-Case

In a concrete example, I have a page with a list of locations in my app.

In another page (accessible from the flyout), I am implementing a complex search functionality.

Upon finding a specific location I would like to navigate to the location list and select the location in question.

Navigating and selecting the location works, but if the location is not in the upper part of the list, it is not visible.

ghost commented 1 year ago

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.