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

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

问题描述

我有一个非常简单的WPF应用程序,其中我使用数据绑定来允许编辑一些自定义CLR对象。我现在想在用户点击保存时进行一些输入验证。但是,我读过的所有WPF书籍并没有真正投入到这个问题上。我看到你可以创建自定义的ValidationRules,但是我想知道这是否会因为我的需要而过度使用。



所以我的问题是:有一个很好的示例应用程序文章在哪里展示了在WPF中验证用户输入的最佳做法?

解决方案

我认为新的首选方式可能是使用IDataErrorInfo



阅读更多 here


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.

So my question is this: is there a good sample application or article somewhere that demonstrates best practice for validating user input in WPF?

解决方案

I think the new preferred way might be to use IDataErrorInfo

Read more here

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

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