

If I remove ValidatesOnDataErrors=True from the text binding then It displays the validation message once in the application written in .Net 4.61 but it never displays in the version written with .Net 4.0.
I am wondering if Its something wrong on my styles and DataTemplate in the App.xaml resources.
Both applications are attached in this message.
@llgarrido I think this is caused by the fact, that we have 2 notifies since 4.5 ValidatesOnNotifyDataErrors and ValidatesOnDataErrors So if both are True we see the error twice. You can handle this by setting
ValidatesOnNotifyDataErrors=True, ValidatesOnDataErrors=False
or
ValidatesOnNotifyDataErrors=False, ValidatesOnDataErrors=True
MahApps understands also ValidatesOnNotifyDataErrors
I am very grateful for your answer @punker76 . I was not aware of the new INotifyDataErrorInfo interface since we started to develop with .Net 4.5 recently.
My problem was that I have a nuget dependency that contains a couple of user controls with ValidatesOnDataErrors=True set in n the xaml and I needed to solve this conflict with our .Net 4.0 applications.
So I decided to write an specific Binding implementation just for those user controls. Taking into account that this dependency is a multi-target nuget package I wrote a conditional compilation to set ValidatesOnDataErrors=True only for .Net 4.0 assemblies:
public class Binding : System.Windows.Data.Binding
{
private void initialize()
{
#if NET40
ValidatesOnDataErrors = true;
#endif
}
public Binding() : base()
{
initialize();
}
public Binding(string path) : base(path)
{
initialize();
}
}
Xaml changes:
<catel:UserControl
xmlns:b="clr-namespace:MyAssembly.Bindings">
<TextBox Text="{b:Binding name, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"/>
</catel:UserControl>
Most helpful comment
I am very grateful for your answer @punker76 . I was not aware of the new INotifyDataErrorInfo interface since we started to develop with .Net 4.5 recently.
My problem was that I have a nuget dependency that contains a couple of user controls with ValidatesOnDataErrors=True set in n the xaml and I needed to solve this conflict with our .Net 4.0 applications.
So I decided to write an specific Binding implementation just for those user controls. Taking into account that this dependency is a multi-target nuget package I wrote a conditional compilation to set ValidatesOnDataErrors=True only for .Net 4.0 assemblies:
Xaml changes: