Xamarin Community Toolkit CharactersValidationBehavior

The CharactersValidationBehavior is a behavior that allows the user to validate text input depending on specified parameters. For example, an Entry control can be styled differently depending on whether a valid or an invalid text value is provided. This behavior includes built-in checks such as checking for a certain number of digits or alphanumeric characters. Additional properties handling validation are inherited from ValidationBehavior.

Syntax

<Entry>
    <Entry.Behaviors>
        <xct:CharactersValidationBehavior
            InvalidStyle="{StaticResource InvalidEntryStyle}"
            CharacterType="Digit"
            MaximumCharacterCount="10"
        />
    </Entry.Behaviors>
</Entry>

Properties

Property Type Description
CharacterType CharacterType Provides an enumerated value to use to set how to handle comparisons.
MaximumCharacterCount int The maximum length of the text input that's allowed.
MinimumCharacterCount int The minimum length of the text input that's allowed.

Sample

You can see this in action in the Xamarin Community Toolkit Sample App.

API