We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

SOLVED: Show Keyboard on sfautocomplete Focus() in iOS

Hi all,

I am very new to Xamarin.Forms and the Syncfusion controls.

I implemented two views with the autocomplete controls

When the view pops I am raising the Focus() event on the autocomplete control in OnAppearing. This raises the keyboard. Perfect.

        protected override void OnAppearing()
        {
            autocomplete.Focus();
        }

However I also have a SAVE button which will save the selected text. I then want to clear the autocomplete and raise the focus event again.
The control does not receive the focus and no keyboard pops up.
I also implemented a custom renderer on the 2nd form, as I wanted the numeric keyboard only. Same problem with the focus on the 2nd time.

btnSave.Pressed += (sender, e) =>
            {
                String r = (String)autocomplete.SelectedItem;

                if (String.IsNullOrEmpty(r))
                {
                    lblResult.Text = "No result";
                    lblResult.BackgroundColor = Color.Red;
                    autocomplete.Text = String.Empty; // or 
autocomplete.Clear(), no difference         
                    autocomplete.Focus();

                }
                else {
                    lblResult.Text = (String)autocomplete.SelectedItem;
                    lblResult.BackgroundColor = Color.Green;
                    autocomplete.Text = String.Empty;
                    autocomplete.Focus();

                }
              

            };

Does anyone have a clue?

All the best from Germany

Marcus


2 Replies

MA Marcus January 16, 2020 05:51 PM UTC

SOLVED it myself.

I is an issue in XAMARIN.FORMS.

I should not have used the PRESSED, but the RELEASED event on the button.
After PRESSED, the RELEASED sets the Focus back to the BUTTON.

Taking Focus() away in PRESSED to

            btnSave.Released += (sender, e) =>
            {
                autocomplete.Focus();

            };

solved it.


RB Rabhia Beham Kathar Mideenar Syncfusion Team January 17, 2020 08:51 AM UTC

Hi Marcus,

Thanks for the update.

Please let us know if you have any other queries.

Regards,
Rabhia Beham K.

Loader.
Live Chat Icon For mobile
Up arrow icon