DataAnnotation in AutoGeneratedPropertyDefinitions=false

5 posts, 1 answers
  1. Vitalij
    Vitalij avatar
    35 posts
    Member since:
    Dec 2010

    Posted 20 Jun 2013 Link to this post

    Hi

    I have a question about DataAnnotation in PropertyGrid when the AutoGeneratedPropertyDefinition is set to false. I have tested the Q1 2013 SP1 for this functionality but no luck. I have VM and defined on each property the DataAnnotation. It is working when AutoGeneratedPropertyDefinition is set to true, but when AutoGeneratedPropertyDefinition is set to false I need to set the DisplayName, Description and so on in every property definition.

    Are you planning to implement such function?

    And it would be great to write the DataAnnotations which I can use in PropertyGrid to the help. There are some, but no all of them. For example the StringLength or Range are working but Required not and so on.

    Thanks 

    Vitalij

  2. Answer
    Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1128 posts

    Posted 25 Jun 2013 Link to this post

    Hi,

     Any of the validation attributes should be properly supported. Have you set Binding's ValidatesOnExceptions property to true and do you throw a validation exceptio when validation result is not the desired one? As for support for the declarative data annotation attributes (i.e. DisplayName) they are only supported for auto-generated property definitions by design. When you create PropertyDefinitions manually, you are free to set whatever DisplayName, GroupName etc you want, so that there is little value in attribute support for such scenarios. 

    Regards,
    Ivan Ivanov
    Telerik

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Vitalij
    Vitalij avatar
    35 posts
    Member since:
    Dec 2010

    Posted 26 Jun 2013 Link to this post

    Hi

    Thanks for the answer. If I get it right, the declarative data annotations works on auto generated properties only. How should I know if the annotation is working or not?? I have set the ValidatesOnDataErrors=True and ValidatesOnExceptions=True and dataanotation Required on property but I cant see any error message that the property is required. Should I implement the Trigger to tho Has Error property to change the style of the control??

    Thanks 

    Vitalij
  5. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1128 posts

    Posted 01 Jul 2013 Link to this post

    Hello,

    "Required" is a bit trickier. If you execute the validation logic in the property setter and nobody sets the property, the validation will never get triggered. Can you please clarify, whether you want to have the validation visible on the initial load (if the property is null), or you want to trigger it at a certain point (i.e. some "commit" operation gets execute)? We should be able to think of some workaround.

    Regards,
    Ivan Ivanov
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    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 >>
  6. Vitalij
    Vitalij avatar
    35 posts
    Member since:
    Dec 2010

    Posted 02 Jul 2013 Link to this post

    Hi

    I have decided to implement additional view for object creation with data validation. So the only problem left is if the user edits the object and erase the data in it, but I can define the IDataErrorInfo interface to avoid this situation. The main purpose of this thread is the data annotation and AutoGeneratedPropertyDefinitions = false which you have already answered.

    Thanks

    Vitalij
Back to Top
UI for WPF is Visual Studio 2017 Ready