[FIXED] Disable picker text input

Issue

On my page, I’m using a picker that bound an ItemSource to 3 selectable items. When I select something from the list or cancel it, the focus stays on the picker and that allows me to type something.
Although this does not affect the value selected, it can be confusing to the user
Is there an easy way to prevent a user from entering data in this field?

Solution

Solution (or a work around) is disabling focus using a custom renderer:

internal class CustomPicker : PickerRenderer
{
    public CustomPicker(Context context) : base(context)
    {
    }

    protected override void OnElementChanged(ElementChangedEventArgs<Picker> e)
    {
        base.OnElementChanged(e);
        EditText?.SetFocusable(ViewFocusability.NotFocusable);
    }
}

Answered By – Cfun

Answer Checked By – Marilyn (Easybugfix Volunteer)

Leave a Reply

(*) Required, Your email will not be published