WPF Validation - ValidatesOnTargetUpdated

I have several text fields in a WPF application on which I set some validation.

Upon loading, the application deserializes the class that the WPF controls are bound to.

I have a ValidationRule that (for example) checks for a file. If I do not set ValidatesOnTargetUpdated then the corresponding TextBox checks when I change the (related) Text property, and I see (by default) a red border appears and a hint ( {Binding RelativeSource={x:Static RelativeSource.Self}, Path=(Validation.Errors).CurrentItem.ErrorContent}) displays an error message.

I want the controls to check for binding, and not on PropertyChanged so I set the ValidatesOnTargetUpdated to true and can see the ValidationRule firing during debugging.

My problem is that the (default) ValidationTemplate is ignored when ValidatesOnTargetUpdated="True", despite the ValidationRule firing.

I see a hint - it appears with the correct error message, but the border does not appear as red; it seems to be ignored.

Any ideas why this is happening?

+3
source share
1 answer

You can read this post. I believe the part that relates to your situation:

Problem: error pattern does not appear when loading page

, , . , / , . ValidatesOnTargetUpdated ValidationRule ; true, . : , DataContext ; , , Loaded. DataContext XAML, : http://wpfglue.wordpress.com/2009/12/08/navigating-from-object-to-object/

, , WPF 4.0.

EDIT:

.

+2

All Articles