Remove WPF Validation decoration from tag

I am using data binding and IDataErrorInfo style identity in the form. This form includes a Label control, for which I do not want to show a red decoration when validation fails. Can anyone recommend a way to remove this decoration from the Label controls?

+4
source share
2 answers

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

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

Hope this helps.

+7
source

, . ValidatesOnNotifyDataErrors, ValidatesOnDataErrors ValidatesOnExceptions.

<Label Content="{Binding YOUR_BINDING_PROPERTY, 
                 ValidatesOnNotifyDataErrors=False,
                 ValidatesOnDataErrors=False,
                 ValidatesOnExceptions=False}" />
0

Source: https://habr.com/ru/post/1737450/


All Articles