Mor Zilberman
Mor Zilberman

Reputation: 105

Using an English only keyboard in a Xamarin.Forms Entry view

Pretty much what the title says.

I have a page with an Entry view in it in my Xamarin.Forms app. Clicking it brings up the software keyboard which, under all text based keyboard settings(such as url, email, text, etc.), has the option to change the input language.

My problem is that my backend accepts English only, and that's the way I want it as well, but I just can't find a way to disable the language choice on the keyboard. Does anyone know?

I'm using Xamarin.Forms, and the above description relates to usage on an Android device, I'm yet to test on iOS.

I'm hoping for a cross platform solution that I can use in the PCL, but a solution using custom renderers is acceptable too if no XForms solution exists.

Thanks!

Upvotes: 0

Views: 1069

Answers (1)

Avi K.
Avi K.

Reputation: 1802

You can do something else to enable only english characters - you can hook to the text changed event of the entry and check inside if the text is english or not.

You can do something like this:

private void MyEntry_TextChanged(object sender, TextChangedEventArgs e)
{
    var newText = ((Entry)sender).Text;
    // Check for english characters. 
    ...
    // If not english, put the old value
    ((Entry)sender).Text = e.OldTextValue;  
}  

Upvotes: 0

Related Questions