Forum General

Announcement:

The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

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 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

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

  • YasinGundogduYasinGundogdu USMember ✭✭

    I had the same problem.

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

    now it is okay.

    Thanks for sharing @PatrickJelitto

Sign In or Register to comment.