forked from xamarinhq/xamu-infrastructure
-
Notifications
You must be signed in to change notification settings - Fork 0
NumericValidationBehavior
Mark Smith edited this page Sep 1, 2016
·
2 revisions
The NumericValidationBehavior class is a custom Xamarin.Forms behavior which can be applied to an Entry control to restrict the input type to be numeric even with a free-form keyboard. Note that this behavior does not change the value of the Entry, it simply changes the visual text color to indicate that the input is not valid. True validation should be done in code behind or in a ViewModel.
-
AllowDecimal: Whentrue, a decimal point is allowed (floating point), whenfalse, only integer values are allowed. Defaults totrue. -
InvalidColor: Color to use for an invalid entry. Defaults toColor.Red.
<Entry Text="{Binding Amount, Mode=TwoWay}">
<Entry.Behaviors>
<inf:NumericValidationBehavior AllowDecimal="true" InvalidColor="Orange" />
</Entry.Behaviors>
</Entry>