Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
20
Localised Category Sort Order
posted

Hi, our product supports multiple languages so we use custom classes for the attributes that perform resource lookups, e.g.

  public class LocalisedCategoryAttribute : CategoryAttribute
  {
      public LocalisedCategoryAttribute( string resourceKey, Type resourceType ) { // use resource manager... }
  }


And in the properties object;

  public class FilePropertiesObject
  {
      [LocalisedCategory("GeneralCategoryName", typeof( Properties.PropertiesResources ) )]
      [LocalisedDisplayName("FileSizeDisplayName", typeof( Properties.PropertiesResources ) )]
      public int FileSize { get; set; }
  }


This works fine, however it appears impossible to apply this technique to the category sort order.  The documentation on CategorySortOrder does mention the argument requirements and there are no name or order properties that can be dynamically returned.  We have a custom CategorySortOrderAttribute class and as hinted at in the doco, the constructor is never called.  Checking the decompiled IG code it is reflecting on the custom attribute and directly extracting the arguments, never constructing an object.

This causes us to multiply define the sort order for each language, since the category itself is changing.

  [CategorySortOrder( "General", 1 )] // English
  [CategorySortOrder( "Общее", 1 )] // Russian
  [CategorySortOrder( "通用", 1 )] // Chinese
  [CategorySortOrder( "Ogólny", 1 )] // Polish
  public class FilePropertiesObject
  {
      [LocalisedCategory("GeneralCategoryName", typeof( Properties.PropertiesResources ) )]
      [LocalisedDisplayName("FileSizeDisplayName", typeof( Properties.PropertiesResources ) )]
      public int FileSize { get; set; }
  }

The drawbacks are that we have to modify the source file whenever the resource changes.  Is there a way to localise this information, or could such a feature be considered for an upcoming release?

Regards,

Logan

Parents
No Data
Reply
  • 1935
    posted

    Hello Logan,

    Thank you for the provided snippet code.

    I have been looking at your scenario and currently CategorySortOrder attribute does not support localizing of the category name parameter.

    What you could do is to create a custom category comparer class that implements IComparer<PropertyGridCategoryItem> where in the Compare method you can specify the general category to be dispalyed as first.

    I have attached a sample where XamPropertyGrid's CategorySortComparer property is set to a CustomCategoryComparer class.

    Regarding the CategorySortOrder attribute, you can suggest new Product Ideas for future versions (or vote for existing ones) at http://ideas.infragistics.com.

    Steps to create your idea:
                   
    1. Log into the Infragistics Product Ideas site at http://ideas.infragistics.com (creating a new login if needed).
    2. Navigate to the product / platform channel of your choice (e.g. WPF, Windows Forms, ASP.NET, HTML5 / Ignite UI, iOS / NucliOS, etc.)
    3. Add your product idea and be sure to be specific and provide as much detail as possible.
    * Explain the context in which a feature would be used, why it is needed, why it can’t be accomplished today, and who would benefit from it. You can even add screenshots to build a stronger case. Remember that for your suggestion to be successful, you need other members of the community to vote for it. Be convincing!
    * [CASE: “Reference case [case number], FORUMS: “Include a link to this thread”] in your idea so product management will be able to look back at this case. 

    The benefits of submitting the product idea yourself include:
    - Direct communication with our product management team regarding your product idea.
    - Notifications whenever new information regarding your idea becomes available.

    Additional benefits of the Product Idea system include:

    - Ability to vote on your favorite product ideas to let us know which ones are the most important to you.  You will have ten votes for this and can change which ideas you are voting for at any time.
    - Allow you to shape the future of our products by requesting new controls and products altogether.
    - You and other developers can discuss existing product ideas with members of our Product Management team.

    The product ideas site allows you to track the progress of your ideas at any time, see how many votes it got, read comments from other developers in the community, and see if someone from the product team has additional questions for you.

    If you require any further assistance on the matter, please let me know.

    XamPropertyGrid_CustomCategoryComparer.zip
Children
No Data