WPF 数据绑定和验证规则最佳实践 [英] WPF Data Binding and Validation Rules Best Practices
问题描述
我有一个非常简单的 WPF 应用程序,我在其中使用数据绑定来允许编辑一些自定义 CLR 对象.我现在想在用户单击保存时进行一些输入验证.然而,我读过的所有 WPF 书籍都没有真正为这个问题投入任何篇幅.我看到您可以创建自定义 ValidationRules,但我想知道这对我的需求来说是否太过分了.
I have a very simple WPF application in which I am using data binding to allow editing of some custom CLR objects. I am now wanting to put some input validation in when the user clicks save. However, all the WPF books I have read don't really devote any space to this issue. I see that you can create custom ValidationRules, but I am wondering if this would be overkill for my needs.
所以我的问题是:是否有好的示例应用程序或文章展示了在 WPF 中验证用户输入的最佳实践?
So my question is this: is there a good sample application or article somewhere that demonstrates best practice for validating user input in WPF?
推荐答案
我认为新的首选方式可能是使用 IDataErrorInfo
I think the new preferred way might be to use IDataErrorInfo
阅读更多这里
这篇关于WPF 数据绑定和验证规则最佳实践的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!