IDataErrorInfo vs IValidatableObject?

前端 未结 2 666
日久生厌
日久生厌 2021-01-17 16:22

Currently my business objects implement IDataErrorInfo. Since I intend to use these libraries in ASP.NET MVC 3, I figure I should implement IValidatableOb

2条回答
  •  半阙折子戏
    2021-01-17 17:14

    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

提交回复
热议问题