Display requirement specific keyboard using Xamarin.Forms
Xamarin uses the Keyboard class to show different virtual keyboards depending upon the user request. It contains several static properties to create different kind of virtual keyboards. Xamarin displays the Default Keyboard, if nothing is specified.
Keyboard for Chatting
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
MainPage = new ContentPage() { Content = new StackLayout() { Children = { new Entry() { Keyboard = Keyboard.Chat } } } }; |
It opens up the default virtual keyboard in the device, which would be convenient for chatting, having few extra keys.
Keyboard for Email entry
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
MainPage = new ContentPage() { Content = new StackLayout() { Children = { new Entry() { Keyboard = Keyboard.Email } } } }; |
It opens up the same text virtual keyboard with some additional options for Email entering.
Keyboard for Numeric input
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
MainPage = new ContentPage() { Content = new StackLayout() { Children = { new Entry() { Keyboard = Keyboard.Numeric } } } }; |
It opens up the numeric virtual keyboard in the device. It helps entering numbers and decimals in the entry field.
Keyboard for Telephone number input
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
MainPage = new ContentPage() { Content = new StackLayout() { Children = { new Entry() { Keyboard = Keyboard.Telephone } } } }; |
This opens up the numeric virtual keyboard in the device with some additional keys like +, *, #, – etc to help user in entering telephone number.
Keyboard for Text input
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
MainPage = new ContentPage() { Content = new StackLayout() { Children = { new Entry() { Keyboard = Keyboard.Text } } } }; |
It opens up a very much similar keyboard as the Default one.
Keyboard for Url input
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
MainPage = new ContentPage() { Content = new StackLayout() { Children = { new Entry() { Keyboard = Keyboard.Url } } } }; |
The keyboard opened up by this method is same as like the Email.
Keyboard to make the first letter of the sentence capitalized
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
MainPage = new ContentPage() { Content = new StackLayout() { Children = { new Entry() { Keyboard = Keyboard.Create(KeyboardFlags.CapitalizeSentence) } } } }; |
It opens up the same Default keyboard but makes first letter of the sentence automatic capitalized
Keyboard for spell checking
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
MainPage = new ContentPage() { Content = new StackLayout() { Children = { new Entry() { Keyboard = Keyboard.Create(KeyboardFlags.Spellcheck) } } } }; |
It opens up the same Default keyboard but checks the spelling during typing.
Keyboard to auto suggest the word
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
MainPage = new ContentPage() { Content = new StackLayout() { Children = { new Entry() { Keyboard = Keyboard.Create(KeyboardFlags.Suggestions) } } } }; |
It opens up the same Default keyboard but suggest the words to the user during typing.
Happy coding 🙂
Categories: Android, Cross Platform Mobile App, CSharp, iOS, Visual Studio, Windows Phone, Xamarin