I'm kind of stuck here.
So what I need is - I have TextBox
that can only have the values from -999
to 999
. I've tried setting the boundaries like so.
<TextBox Height="{Binding ElementName= SomeComboBox, Path=ActualHeight}"
VerticalAlignment="Top"
Tag="int"
HorizontalAlignment="Stretch"
MaxLength="4"
Margin="2, 4, 0, 0"
AutomationProperties.AutomationId="Something_cbSome">
<i:Interaction.Behaviors>
<behaviors:TextBoxIntInputBehavior AllowNegative="True" />
</i:Interaction.Behaviors>
<TextBox.Text>
<Binding Path="Something"
UpdateSourceTrigger="PropertyChanged"
TargetNullValue="">
<Binding.ValidationRules>
<validation:IntRangeRule Min="-999"
Max="999" />
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
But the obviously now someone can enter 4 digits since the MaxLength
has the value 4
. For example 1234
which is higher than the 999
.
Also, this allows me to type in things like ---
, 8--2
etc.
Desired accepted values : -999
up to 999
. No more, no less. How do I do this?