IDataErrorInfo 与 IValidatableObject?

发布于 2024-10-03 17:05:00 字数 191 浏览 0 评论 0原文

目前我的业务对象实现了IDataErrorInfo。由于我打算在 ASP.NET MVC 3 中使用这些库,因此我认为我也应该实现 IValidatableObject ,或者也可以代替。

WPF 是否可以与 IValidatableObject 一起使用?

数据注释如何融入图片?

Currently my business objects implement IDataErrorInfo. Since I intend to use these libraries in ASP.NET MVC 3, I figure I should implement IValidatableObject as well or maybe instead of.

Does WPF work with IValidatableObject?

How do DataAnnotations fit into the picture?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

樱娆 2024-10-10 17:05:00

IValidatableObject 是一个用于验证整个对象级别错误的接口。您有责任通过验证数据注释或其他技术来实现它。 MVC 对数据注释具有本机支持,因此您可以直接使用它们而无需任何进一步的支持。

相反,wpf 仅支持 IDataErrorInfo。它不支持 IValidateObject 或 DataAnnotations。

不过,我实现了一个包装对象,它将 Wpf 中的 DataAnnotation 支持添加到包装对象中。它还提供了 IPropertyChanged 的​​实现。请参阅 codeplex 上的Wpf 和 Silverlight 验证工具包

IValidatableObject is an interface for verifying whole object level errors. It is your responsibility to implemts it by verifying data annotations or other techniques. MVC has native support for data annotations so you can just use them without any further support.

On the contrary wpf ONLY SUPPORTS IDataErrorInfo. It has no support for IValidateObject or DataAnnotations.

However I implemented a wrapper object that add DataAnnotation support in Wpf to the wrapped object. It furnishes also an implementation of IPropertyChanged. See the Validation Toolkit for Wpf and Silverlight on codeplex

山色无中 2024-10-10 17:05:00

我正在实体上实现 IValidatableObject ,并在 WPF 的视图模型中用 IDataErrorInfo 包装它(自动通过基类)。我的实体将在 WPF、MVC 和新的 EF CTP5 中运行良好,它们也支持 IValidatableObject

I am implementing IValidatableObject at entity, wrapping it with IDataErrorInfo at view model (automatically via base class) for WPF. My entities will work well in either WPF, MVC and new EF CTP5 who also honors IValidatableObject.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文