Localization of Property Grid

7 posts, 0 answers
  1. Robert
    Robert avatar
    4 posts
    Member since:
    Mar 2014

    Posted 07 Apr 2014 Link to this post

    I wanting to utilize the PropertyGrid in a application. I have a requirement to support multiple languages. What is the best approach to localize the strings displayed to the user? I am referring the Property Names, and Property Descriptions. I would also like to categorize properties and would like the categories translated.

    I have tried an approach I found on CodeProject, but it is designed for WinForms and not WPF. It uses a GlobalPropertyDescriptor which is derived from PropertyDescriptor. This class overrides the Name, DisplayName, and Description properties to retrieve localized strings from string tables. The problem to the approach is the getters for the DisplayName and Description properties are never accessed. The Name property is accessed.

    Each class displayed in a PropertyGrid inherits from a common base class that implements an ICustomTypeDescriptor. Most of the what happens here is in the GetProperties functions.

    Bottom line is this approach is not working for the WPF version of the PropertyGrid and I am looking for some guidance.
    Any assistance is greatly appreciated.
  2. Robert
    Robert avatar
    4 posts
    Member since:
    Mar 2014

    Posted 08 Apr 2014 Link to this post

    I have added the following attribute to one of my properties.

    [Display(ResourceType = typeof(DisplayResources), Name = "VerificationTime", Description = "VerificationTimeDescription", GroupName = "VerificationTimeGroup")]

    I have string table for each support language.
    DisplayResources is where my string tables are.
    VerificationTime, VerificationTimeDescription, and VerificationTimeGroup all exists as Names each of my string tables. Each name in the string table has the desired Value to be displayed.

    Name is the only string that is correctly translated, leading me to believe the access to the resource is correct.
    Why can't I localize Description, and GroupName?

  3. UI for WPF is Visual Studio 2017 Ready
  4. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 10 Apr 2014 Link to this post

    Hello,

    The built-in localization for RadPropertyGrid supports localizing just two values. As to it, you can check our online documentation on Localization for RadPropertyGrid  and the general article on the built-in Localization mechanisms.
     
    Apart from that you can also apply your own localization through data annotations attributes. This is what you are actually trying to do. I have attached a test solution demonstrating how this can be achieved.

    I hope the solution works for you.

    Regards,
    Didie
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  5. Robert
    Robert avatar
    4 posts
    Member since:
    Mar 2014

    Posted 10 Apr 2014 in reply to Dimitrina Link to this post

    Thank you for your help. Your solution works perfectly.

    In my solution I am still having problems. There are some subtle differences, but basically I ended up using the same approach as in your solution. Here are the differences.
    I am using a trial version of 2014.1.331.45.
    My ViewModels are in a separate class library. I using the resources from that library.
    I am using a fair amount of inheritance in my view models, but one of the properties has the attributes applied to the actual class I am binding to.

    In my solution the Name works correct, but the Description and GroupName do not.
    Setting break points on the VerificationTime, VerificationTimeDescription, and VerificationTimeGroup properties of my Resources class I can see that VerificationTime getter is accessed, but the others are not.

    I was going to send my project Attach files does not support zip files.
  6. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 11 Apr 2014 Link to this post

    Hello,

    The trial version should not make any difference in the behavior you get. Would you please open a support ticket and send us the demo solution?
    That way we will check it locally and advise further.

    Regards,
    Didie
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  7. Robert
    Robert avatar
    4 posts
    Member since:
    Mar 2014

    Posted 14 Apr 2014 Link to this post

    If the RadPropertyGrid is being used to edit a collection of objects the localization does not work as expected. In my case the Name of the property is localized but not the description or group name.

    It's too bad, because I really need the multiple object PropertySetModes and the localization. Each work, but not at the same time. 
  8. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 15 Apr 2014 Link to this post

    Hello,

    I am glad to let you know we found the reason for this behavior and we managed to resolve the issue. The fix is expected to be included in the next latest internal build.

    Regards,
    Didie
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top
UI for WPF is Visual Studio 2017 Ready