name |
description |
page_type |
languages |
products |
urlFragment |
Xamarin.Forms - Numeric validation behavior with style |
Xamarin.Forms behaviors can be consumed by an explicit or implicit style. This sample shows how to consume a behavior with an explicit style |
sample |
|
|
behaviors-numericvalidationbehaviorstyle |
Numeric Validation Behavior with Style
Xamarin.Forms behaviors can be consumed by an explicit or implicit style. This sample demonstrates how to consume a Xamarin.Forms behavior with an explicit style.
<ContentPage.Resources>
<ResourceDictionary>
<Style x:Key="NumericValidationStyle" TargetType="Entry">
<Style.Setters>
<Setter Property="local:NumericValidationBehavior.AttachBehavior" Value="true" />
</Style.Setters>
</Style>
</ResourceDictionary>
</ContentPage.Resources>
<StackLayout Padding="10,50,10,0">
<Label Text="Red when the number isn't valid" FontSize="Small" />
<Entry Placeholder="Enter a System.Double" Style="{StaticResource NumericValidationStyle}" />
</StackLayout>
For more information about this sample, see Behaviors.