This is a migrated thread and some comments may be shown as answers.

DataAnnotation in AutoGeneratedPropertyDefinitions=false

4 Answers 80 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
Vladimir
Top achievements
Rank 1
Vladimir asked on 20 Jun 2013, 07:58 AM
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

4 Answers, 1 is accepted

Sort by
0
Accepted
Ivan Ivanov
Telerik team
answered on 25 Jun 2013, 05:16 AM
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.

0
Vladimir
Top achievements
Rank 1
answered on 26 Jun 2013, 02:43 PM
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
0
Ivan Ivanov
Telerik team
answered on 01 Jul 2013, 03:05 PM
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 >>
0
Vladimir
Top achievements
Rank 1
answered on 02 Jul 2013, 06:42 AM
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
Tags
PropertyGrid
Asked by
Vladimir
Top achievements
Rank 1
Answers by
Ivan Ivanov
Telerik team
Vladimir
Top achievements
Rank 1
Share this question
or