Validation error template - binding exception

前端 未结 1 1224
死守一世寂寞
死守一世寂寞 2021-02-19 01:00

I am using the following template for validation error:


    
            


        
1条回答
  •  心在旅途
    2021-02-19 01:51

    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
    

    0 讨论(0)
提交回复
热议问题