This project has moved and is read-only. For the latest updates, please go here.

Validation Markup for custom DataAnnotation on Entity

Apr 19, 2012 at 7:48 PM


I have custom data annotation attribute which is applied to whole class (not to single property). Could anybody please point me how to show it in markup (XAML) (BookLibrary example seems not working because annotations are applied to a property)

Thanks in advance,


Apr 21, 2012 at 8:38 PM
Edited Apr 21, 2012 at 8:40 PM

The BookLibrary example uses the DataErrorInfoSupport class for supporting the DataAnnotation validation. It validates only the Property attributes. You could rewrite this class to validate the object validation attributes as well.

// Validates only property attributes
    new ValidationContext(instance, null, null) 
        { MemberName = memberName }, validationResults);

Note: This might have some performance impact.