<Binding Path="AttachmentName" UpdateSourceTrigger="PropertyChanged">
<Binding.ValidationRules>
<valid:AttachmentNameValidationRule ValidationStep="RawProposedValue" ValidatesOnTargetUpdated="True"/>
</Binding.ValidationRules>
</Binding>
Validator checks if entered value is in proper format: file.extension. Unfortunelly, textBox is red when control IsEnabled == false (because content is "").
Any idea how to disable validation? Tried some stuff with x:referense and passing UIElement to validator, but didnt work.
The original credit goes to the link in @ydoow's answer.
It is easily achieved with a trigger that sets the Validation.ErrorTemplate
to null when the control is disabled.
The property is still validated but user is not notified about validation results.
<Style TargetType="TextBox" BasedOn="{StaticResource {x:Type TextBox}}">
<Style.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Validation.ErrorTemplate" Value="{x:Null}"/>
</Trigger>
<Trigger Property="IsEnabled" Value="True">
<Setter Property="Validation.ErrorTemplate" Value="{StaticResource ErrorTemplate}"/>
</Trigger>
</Style.Triggers>
</Style>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With