Xamarin.Forms CustomRenderer BorderlessPicker Items not in list

PatrickJelittoPatrickJelitto Member ✭✭✭

Hi Guys,

i implemented the BorderlessPicker like shown in this Tutorial:
https://alexdunn.org/2017/07/24/xamarin-tip-borderless-picker/comment-page-1/#comment-1664

Now i have the problem that the new Picker looks like this:

instead of the standart one looking like this:

Does someone know how to make the CustomPicker look like the standart one?
Here the Code of the Custom one:

[assembly: ExportRenderer(typeof(BorderlessPicker), typeof(BorderlessPickerRenderer))]
namespace SuaveControls.MaterialForms.Android.Renderers
{
    public class BorderlessPickerRenderer : PickerRenderer
    {
        public static void Init() { }
        protected override void OnElementChanged(ElementChangedEventArgs<Picker> e)
        {
            base.OnElementChanged(e);
            if (e.OldElement == null)
            {
                Control.Background = null;

                var layoutParams = new MarginLayoutParams(Control.LayoutParameters);
                layoutParams.SetMargins(0, 0, 0, 0);
                LayoutParameters = layoutParams;
                Control.LayoutParameters = layoutParams;
                Control.SetPadding(0, 0, 0, 0);
                SetPadding(0, 0, 0, 0);
            }
        }
    }
}

Thank you

Best Answers

  • PatrickJelittoPatrickJelitto ✭✭✭
    Accepted Answer

    @seanyda Thank you very much.The stackoverflow link helped me alot.
    All i had to do is let the BorderlessPickerRenderer inherit from

    Xamarin.Forms.Platform.Android.AppCompat.PickerRenderer
    instead of
    Xamarin.Forms.Platform.Android.PickerRenderer

    and it was all done.

    Greets from Germany, Gelatto

Answers

  • PatrickJelittoPatrickJelitto Member ✭✭✭
    Accepted Answer

    @seanyda Thank you very much.The stackoverflow link helped me alot.
    All i had to do is let the BorderlessPickerRenderer inherit from

    Xamarin.Forms.Platform.Android.AppCompat.PickerRenderer
    instead of
    Xamarin.Forms.Platform.Android.PickerRenderer

    and it was all done.

    Greets from Germany, Gelatto

Sign In or Register to comment.