I have a TextBox which is linked to a double? in my backend viewModel. I need the ConvertBack to trigger when I empty the TextBox, but the validationRule "ValidateNotNullOrWhiteSpace" fail so there is no call to ConvertBack. My problem is that when I empty the textBox I want the viewModel to be null. Right now the viewModel keep the old value exemple 10.
Is there a way to force the binding even when ValidationRules fail?
<TextBox x:Name="txtSlabDepth" Grid.Row="0" Grid.Column="1" Margin="0,3,0,0"
TextAlignment="Right" MaxLength="15"
KeyDown="Textbox_KeyDown" TextChanged="Textbox_TextChanged" >
<Binding Path="SlabDepth">
<Binding.Converter>
<converters:LengthInchTextboxConverter x:Name="LengthInchTextboxConverter_SlabDepth" />
</Binding.Converter>
<Binding.ValidationRules>
<validations:ValidateLength x:Name="ValidateLength_SlabDepth"/>
<validations:ValidateNotNullOrWhiteSpace x:Name="ValidateNotNullOrWhiteSpace_SlabDepth"/>
</Binding.ValidationRules>
</Binding>
<TextBox.Style>
<Style TargetType="TextBox">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=IsSlabDepthModified}" Value="True">
<Setter Property="Background" Value="Yellow" />
</DataTrigger>
</Style.Triggers>
</Style>
</TextBox.Style>
</TextBox>
Thank you.