5

I am using databinding and IDataErrorInfo style validation in a form. This form includes a Label control for which I don't want to show the red adornment when validation fails. Can anyone recommend a way to remove this adornment from Label controls?

BrettRobi
  • 3,793
  • 7
  • 40
  • 64

2 Answers2

10

You can get rid of the default validation error template by assigning an empty ControlTemplate to the attached property Validation.ErrorTemplate.

<Label Content="{Binding ...}">
  <Validation.ErrorTemplate>
    <ControlTemplate />
  </Validation.ErrorTemplate>
</Label>

Hope this helps.

Oskar
  • 7,945
  • 5
  • 36
  • 44
2

You can disable validation for a Binding by disabling the relevant Validation mode. These can be one or all of ValidatesOnNotifyDataErrors, ValidatesOnDataErrors and ValidatesOnExceptions.

<Label Content="{Binding YOUR_BINDING_PROPERTY, 
                 ValidatesOnNotifyDataErrors=False,
                 ValidatesOnDataErrors=False,
                 ValidatesOnExceptions=False}" />
FlyingFoX
  • 3,379
  • 3
  • 32
  • 49