Have Picker scroll to currently selected item on dropdown of the list

Lloyd Sheen 1,386 Reputation points
2022-04-08T17:45:44.487+00:00

Cannot find anything about how to cause the Picker control to scroll to the selected item when the dropdown is opened.

I have a Picker that can have many items and it is a pain having to scroll manually to get to where you were on last selection. Also when you do scroll there is no indication of what item was selected (I know it is in the top of the Picker control).

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,296 questions
{count} vote

1 answer

Sort by: Most helpful
  1. Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.) 26,451 Reputation points Microsoft Vendor
    2022-04-11T07:40:54.127+00:00

    Hello,

    On iOS platform, it will scroll to the selected item when the picker is opened. But on Android platform, the picker can't scroll to the selected item.

    In the Android source code, we can see there is a NumberPicker displaying the string value. We need to record the scrollX and scrollY when an item is selected so that we can scroll the picker by ScrollBy or ScrollTo method when the picker is open.

    But this NumberPicker is a local variable, we can't get the instance even through Custom Renderers (PickerRenderer). So I have to say, you can't implement this feature by the current API. You could try to create a new issue on GitHub for your feature request:
    https://github.com/xamarin/Xamarin.Forms/issues/new/choose

    Best Regards,
    Wenyan Zhang


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments