0

I am trying to get my picker to be an wheel/spinning type.

enter image description here

My Current Picker:

<Picker x:Name="AmountPicker" />
AmountPicker.ItemsSource = new List<string>() { "1", "2", "3","4","5","6","7","8" };

My Picker

Skin
  • 9,085
  • 2
  • 13
  • 29
Monogon
  • 3
  • 2

1 Answers1

1

You have a couple of options.

1. Use Custom Renderers which enables you to achieve the wheel/spinning type. There is a similar thread you could refer to: Apply styles on Picker items in Xamarin Forms.

1.1 Create the Custom Picker Control in Shared Project:

    public class MyPicker : Picker
    {
    }

1.2 Creating the Custom Renderer on Android & iOS:

Android:

using Xamarin.Forms; 
using Xamarin.Forms.Platform.Android;

[assembly: ExportRenderer(typeof(MyPicker), typeof(MyPickerRenderer))]
namespace App35.Droid
{
    class MyPickerRenderer : PickerRenderer
    {

        public MyPickerRenderer(Context context) : base(context)
        {
        }
    }
}

iOS:

[assembly: ExportRenderer(typeof(MyPicker), typeof(MyPickerRenderer))]
namespace App35.iOS
{
    class MyPickerRenderer : PickerRenderer
    {

        protected override void OnElementChanged(ElementChangedEventArgs<Picker> e)
        {
            base.OnElementChanged(e);
        }
    }
}

1.3 Consume it in XAML:

   <local:MyPicker ItemsSource="{Binding MyListProperty}" ></local:MyPicker>

Output:

enter image description here

2. Use Xamarin.SfPicker. Firstly, install the package and then set SfPicker control namespace as xmlns:syncfusion="clr- namespace:Syncfusion.SfPicker.XForms;assembly=Syncfusion.SfPicker.XForms in XAML Content page. So you can consume it in XAML like below.For more you can refer to Getting Started with Xamarin Picker (SfPicker)

   <syncfusion:SfPicker x:Name="picker" HeaderText="Choose Value" />

3. Use Wheel Picker for Xamarin Samples package, you can refer to Wheel Picker for Xamarin Samples for more details.

Alexandar May - MSFT
  • 6,536
  • 1
  • 8
  • 15