'How to set Keyboard Type in Xamarin android using MVVMCross?

I'm new to MVVMCross and trying to change keyboard type of Input field based on setting. I tried to achieve this by creating convertor but no luck. Please help me if you can.

Thank you in advance.



Solution 1:[1]

You can customize your keyboard with Keyboard property, as following shows

Chat – used for texting and places where emoji are useful.
Default – the default keyboard.
Email – used when entering email addresses.
Numeric – used when entering numbers.
Plain – used when entering text, without any KeyboardFlags specified.
Telephone – used when entering telephone numbers.
Text – used when entering text.
Url – used for entering file paths & web addresses.

Here is a document you can refer to https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/text/entry

Update:

I bind the switch with Entry.Keyboard using Converter code like following:

<ContentPage.Content>
        <StackLayout Orientation="Horizontal"
                     VerticalOptions="CenterAndExpand">
            <Label Text="switch keyborad"/>
            <Entry BackgroundColor="AliceBlue">
                <Entry.Keyboard>
                <Binding Source="{x:Reference myswitch}"
                         Path="IsToggled">
                    <Binding.Converter>
                        <local:KeyboardConverter x:TypeArguments="Keyboard"
                                                 TrueValue="Keyboard.Chat"
                                                 FalseValue="Keyboard.Numeric"/>
                    </Binding.Converter>
                </Binding>
                    </Entry.Keyboard>
            </Entry>
            <Switch x:Name="myswitch"/>
        </StackLayout>
    </ContentPage.Content>

Converter:

 public class KeyboardConverter<T>:IValueConverter
    {
        public T TrueValue { set; get; }
        public T FalseValue { set; get; }
        public KeyboardConverter()
        {
        }

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return (bool)value ? TrueValue : FalseValue;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return ((Object)value).Equals(TrueValue);
        }
    }


    <ContentPage.Content>
        <StackLayout Orientation="Horizontal"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1