Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

How to set the default list style from Xamarin Forms Picker

$
0
0

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


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>