Custom data annotation (for internationalization)

5 posts, 0 answers
  1. OBollmann
    OBollmann avatar
    14 posts
    Member since:
    Jan 2007

    Posted 24 Sep 2010 Link to this post


    with data annoations (DisplayAttribute) it is possible to create custom descriptions for the filtered properties. But unfortunately the DisplayAttribute is sealed. So it is not possible to inherit from this Attribute to implement internationalization from resource files. (I did something equal with the DescriptionAttribute which is not sealed). Is it possible to create custom property descriptions in a different way? Perhaps with ItemPropertyInfo class? At first sight it seems that it is not possible. In constructor of ItemPropertyInfo you can set name, type and descriptor. Name is obviously used for creating FilterDescriptors so the name must represent the real path to the property and could not be a user readable name. The type is the type ;-) And the descriptor is a PropertyInfo instance which contains the real name of the property again. Is there a way to accomplish my request?

    Best regards,
  2. Rossen Hristov
    Rossen Hristov avatar
    2478 posts

    Posted 28 Sep 2010 Link to this post

    Hello OBollmann,

    We will obsolete the usage of ItemPropertyInfo's with the Q3 release, just for the reason you have mentioned -- they are hard to create and even harder to modify.

    We will replace them with our own ItemPropertyDefinition class, which will have the following properties:

    - PropertyName: the name of the prop, can be complex nested prop, i.e. with dots.
    - PropertyType: well, the type
    - DisplayName: what the UI will show -- I think this will be perfect for localization.

    These objects will be DependencyObjects and you will be able to bind to all of their props.

    Do you think that this will solve your requirements?

    Kind regards,
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. DevCraft R3 2016 release webinar banner
  4. OBollmann
    OBollmann avatar
    14 posts
    Member since:
    Jan 2007

    Posted 28 Sep 2010 Link to this post

    That would be cool!! I will give it a try!

    Best regards,
  5. srecov
    srecov avatar
    7 posts
    Member since:
    Jul 2013

    Posted 11 Aug 2013 Link to this post




    I hope your solution is already in production. Wuld you please give me an example how to use localization in data annotation. Both annotations are from standard silverlight business template using RIA. I am replacing standard controls with telerik. I am already using ResourceManager telerik localization for key strings and it is working ok. I do not know what type of resource I have to write. When I use my new KeyStrings.resx  for Telerik localization, I get an error: "Cannot retrive property 'Name' because localization failed."


    // silverlight project code behind for login control
    [Display(Name = "PasswordLabel", ResourceType = typeof(RegistrationDataResources))]
    //web project services metadata...server side validation
    [Required(ErrorMessageResourceName = "ValidationErrorRequiredField", ErrorMessageResourceType = typeof(ValidationErrorResources))]




  6. Dimitrina
    Dimitrina avatar
    3769 posts

    Posted 15 Aug 2013 Link to this post


    We have already replied to your support thread on the same matter and I am also pasting our answer below.

    The provided Data Annotation seems to work at our side, just make sure that you have the string added in the .resx file. In order to make the .resx files available for both the Web project and the Silverlight project, you should add them inside the Web project and link them in the client project, the approach is explained in details in the following blog post:

    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 >>
Back to Top
DevCraft R3 2016 release webinar banner