Validation error template - binding exception Validation error template - binding exception wpf wpf

Validation error template - binding exception


When there are no validation errors, the binding is still trying to access the first element in the ReadOnlyObservableCollection returned by Validation.Errors, but because it is empty, an exception is thrown.

The binding system just swallows the exception, but its still annoying and unnecessary.

Instead of binding like this:

Path=AdornedElement.(Validation.Errors)[0].ErrorContent

..you can do it like this, to avoid the exception:

Path=AdornedElement.(Validation.Errors).CurrentItem.ErrorContent