Class Validation

2 posts, 0 answers
  1. JJ
    JJ avatar
    1 posts
    Member since:
    Dec 2013

    Posted 29 Jan 2014 Link to this post


    I'm using property grid to change an underlying class model.
    All my class' properties have data annotations like RequiredAttribute, StringLengthAttribute etc, and my class implements IDataErrorInfo.
    In my this[column] indexer of the class I iterate the property to get all attributes related to it and validate all, building the error message accordingly.
    When property value change, I raise the INotifyPropertyChanged event and things get going in the UI. Property grid responses well to changes in the model class signaling the errors defined by my attributes annotations. So far so good...

    But now I need to implement class level validation rather than only property validation. As mentioned, the last one is working perfectly. I need to implement some feature to signal propertygrid about class level error when, for instance, two date property don't match together.
    I tried to add those class level errors in Error member of IDataErrorInfo with no success... allthough the Error property returns an error string, the property grid ignores it and do not show anything. For instance, when using GridView, it signals the entire record when assigning a set of those classes as datasource of the grid... it detects the Error property returning an error message and responds to it... but not propertygrid.

    How can I validate class level errors with PropertyGrid?

    Best regards,

  2. Dimitrina
    Dimitrina avatar
    3769 posts

    Posted 03 Feb 2014 Link to this post

    Hi Jorge,

    I am afraid this would not be possible. You can only validate on a property level.

    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. DevCraft R3 2016 release webinar banner
Back to Top