开发者

DataAnnotations Validation only implemented in MVC?

开发者 https://www.devze.com 2023-03-19 02:09 出处:网络
I somehow missed the introduction of DataAnnotations.I’ve been looking at them off and on for the last couple of weeks.It seems like everything I’m finding ties back to MVC.Are there any full implem

I somehow missed the introduction of DataAnnotations. I’ve been looking at them off and on for the last couple of weeks. It seems like everything I’m finding ties back to MVC. Are there any full implementations for doi开发者_如何学运维ng validation with WPF, WinForms, etc.?

If so, any pointers/links would be appreciated.

If not, are there plans to introduce integrated support in the future?

My current interests lie in WPF so that's really what I'm looking for.

TIA


Karl Shifflett from the Microsoft patterns and practices team has a detailed video on how to use the Data Annotations attributes in WPF. His source code is available via a link at the bottom of his blog post on his Stuff demo application.

Data Annotations is a nice middle ground between that and the ad-hoc validation one would normally see in the WPF books and tutorials and the more powerful Enterprise Validation Application Block that @Evan Larsen mentioned above. Plus, as you noticed, using Data Annotations allows for sharing of models with ASP.NET applications.


Regarding WPF, DataAnnotations support is not built in, but it shouldn't be too difficult to hook in to your own app.

The demo app of my open source library PDX shows one way to do it, but the documentation for 0.2 isn't quite finished yet :)

Here's another way to do it: http://babaandthepigman.wordpress.com/2010/02/14/wpf-commanding-and-data-annotations-validation/

0

精彩评论

暂无评论...
验证码 换一张
取 消