WPF数据绑定和验证规则的最佳实践 [英] WPF Data Binding and Validation Rules Best Practices

查看:370
本文介绍了WPF数据绑定和验证规则的最佳实践的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常简单的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?

推荐答案

我觉得pferred方式,新的$ P $可能是使用IDataErrorInfo

I think the new preferred way might be to use IDataErrorInfo

了解更多这里

这篇关于WPF数据绑定和验证规则的最佳实践的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆