[英]How to validate a different property that the one changed using IDataErrorInfo with WPF without calling property changed?
[英]How to validate a different property that the one changed using IDataErrorInfo with WPF?
我正在使用IDataErrorInfo来验证我的视图模型,因为它允许我使用清晰的xaml sintax,并且一旦获得它就非常简单。
我的问题是,当另一个属性更改时,如何验证一个属性,因为验证不仅取决于单元格上的值,还取决于其他属性。 我看到只有在属性值更改时才调用验证方法。
提前致谢。
使用IDataErrorInfo您可以将其连接
public string this[string columnName]
通过覆盖它,或者自己编写。
在您的情况下,请检查columnName是否等于您要验证的属性,然后返回带有值的字符串以表示验证错误,或者返回null表示没有错误。
另外,为确保重新验证它,在从属属性更新时,请确保对main属性执行OnPropertyChanged
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.