The property Keyboard is set more than once

JassimRahmaJassimRahma USMember ✭✭✭✭

Hi,

I am trying to set the CapitalizeCharacter for an Entry which already has the Keyboard="Default" but getting:

The property Keyboard is set more than once

How can I fix this please?

Here is my code:

<Entry x:Name="TextBoxSignupFirstName" IsTextPredictionEnabled="False" IsSpellCheckEnabled="False" Keyboard="Default" FlowDirection="LeftToRight" HorizontalTextAlignment="Center">
    <Entry.Keyboard>
        <Keyboard x:FactoryMethod="Create">
            <x:Arguments>
                <KeyboardFlags>Suggestions,CapitalizeCharacter</KeyboardFlags>
            </x:Arguments>
        </Keyboard>
    </Entry.Keyboard>
</Entry>

Thanks,
Jassim

Tagged:

Best Answer

Answers

  • LandLuLandLu Member, Xamarin Team Xamurai
    <Entry.Keyboard>
        <Keyboard x:FactoryMethod="Create">
            <x:Arguments>
                <KeyboardFlags>Suggestions,CapitalizeCharacter</KeyboardFlags>
            </x:Arguments>
        </Keyboard>
    </Entry.Keyboard>
    

    This code is used for creating a keyboard for your Entry using flags. This is another way for instanstiating a keyboard so we can't use Keyboard="Default" again in xaml. Or it will cause a conflict.
    Moreover, Suggestions,CapitalizeCharacter will open the default keyboard and add new features:
    https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/text/entry#customizing-the-keyboard

  • JassimRahmaJassimRahma USMember ✭✭✭✭

    Yeah but what if I want a Email and URL Keyboard and Suggestion Flag?

  • LandLuLandLu Member, Xamarin Team Xamurai

    They are two different keyboard types we can't consume them all at the same time. If you want Suggestion flag the keyboard type can only be default.
    We could use some suggestion box libraries to achieve it. i.e.
    https://github.com/dotMorten/XamarinFormsControls/tree/master/AutoSuggestBox

  • JassimRahmaJassimRahma USMember ✭✭✭✭

    Hi @LandLu

    I tried this code:

    <Entry x:Name="TextBoxSignupFirstName" IsTextPredictionEnabled="False" IsSpellCheckEnabled="False" FlowDirection="LeftToRight" HorizontalTextAlignment="Center">
        <Entry.Keyboard>
            <Keyboard x:FactoryMethod="Create">
                <x:Arguments>
                    <KeyboardFlags>Suggestions,CapitalizeCharacter</KeyboardFlags>
                </x:Arguments>
            </Keyboard>
        </Entry.Keyboard>
    </Entry>
    

    but I am getting:

    Type 'Keyboard' is not usable as an object element because it is not public or does not define a public parameterless constructor or a type converter.

    The attribute 'FactoryMethod' from the XAML namespace is not defined.

Sign In or Register to comment.