Reputation: 2220
Is there a collection that I can use in my application where I can ignore the DataErrors? Currently, my BusinessObject implements the IDataErrorInfo interface, but I have a readonly control that I do not want to receive those notifications.
I tried using a DataTemplate with a TextBlock that has the property ValidatesOnDataErrors=False, but this didn't work.
Any ideas?
Upvotes: 2
Views: 133
Reputation: 15579
You could set the control's Validation.ErrorTemplate
to null using a style.
<Style TargetType="Control">
<Style.Triggers>
<Trigger Property="Validation.HasError" Value="true">
<Setter Property="Validation.ErrorTemplate" Value="{x:Null}" />
</Trigger>
</Style.Triggers>
</Style>
Also, to clarify, the "ValidatesOnDataErrors" property should be used on the binding not the control itself.
The other alternative is to wrap your bound objects in some view model/adapter that doesn't implement IDataErrorInfo
.
Upvotes: 4