How to set the default list style from Xamarin Forms Picker

Hi all, I've created a custom renderer for the picker control in xamain forms. The main reason was to add a bindable property to set the "placeholder" color text. Once making the renderer for the picker the list style box for android only (ios working) and changed.

Box of box Picker List Style

<Picker.Items>
<x:String>Male</x:String>
<x:String>Female</x:String>
</Picker.Items>
</Picker>

Then once making the customer renderer the box list style changes to this

 <local:WhitePicker x:Name="Gendertxt" Title="Gender" TextColor="White" PlaceholderColor="#cccccc" HorizontalOptions="FillAndExpand">
<Picker.Items>
<x:String>Male</x:String>
<x:String>Female</x:String>
</Picker.Items>
</local:WhitePicker>

Android Picker Custom Renderer

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

       // this.Control.Background = Forms.Context.GetDrawable(Resource.Drawable.CustomPickerBackground);
        //Control?.SetPadding(20, 20, 20, 20);
        if (e.OldElement != null || e.NewElement != null)
        {
            var customPicker = e.NewElement as WhitePicker;

            Control.SetHintTextColor(Android.Graphics.Color.ParseColor(customPicker.PlaceholderColor));
            Control.BackgroundTintList = ColorStateList.ValueOf(Android.Graphics.Color.White);

        }

Is there anyway to change the list style to the out of the box style?

Thanks

Answers

  • ledragonledragon Member ✭✭

    Did you find an answer to this? Just come across the same.

  • BjrnMllerBjrnMller USMember

    Same problem here. No solution found yet.

Sign In or Register to comment.