I'm trying to write a simple behavior with max- and min- values to validate an entered value within a certain range:
<Entry Text="{Binding Quantity, Mode=TwoWay}">
<Entry.Behaviors>
<ui:ValueInRangeValidator x:Name="QtyValidator" MinValue="1" MaxValue="10"/>
</Entry.Behaviors>
</Entry>
This works fine, but when trying to add binding eg. MaxValue="{Binding MaxVal}" the value is left as it's default.
I'm using the following in my behavior:
public static BindableProperty MaxValueProperty =
BindableProperty.Create("MaxValue", typeof(decimal?), typeof(ValueInRangeValidator));
public decimal? MaxValue
{
get { return (decimal?)GetValue(MaxValueProperty); }
set
{
SetValue(MaxValueProperty, value);
OnPropertyChanged();
}
}
I've also tried setting the property changed event on the BindableProperty but it never seems to fire. I know the viewmodel is correct as binding the same property to a label displays the value.