Xamarin.Forms - 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.