wpftoolkit icon indicating copy to clipboard operation
wpftoolkit copied to clipboard

PropertyGrid - Is it possible use the Attribute Description in Enums?

Open kabircosta opened this issue 3 years ago • 1 comments

Hi developers, a question:

is it possible, in a PropertyGrid, to display the Description attribute of an Enum in the ComboBoxitems instead of displaying the name?

public enum ExampleEnum
{
    [Description("First Item")] // Use that
    FirstItem = 1,              // Instead of that

    [Description("Second Item")]
    SecondItem = 2,

    [Description("Third Item")]
    ThirdItem = 3
}

Here is a reference link that describes my question: https://code.4noobz.net/wpf-enum-binding-with-description-in-a-combobox/

Any help is greatly appreciated.

kabircosta avatar Aug 23 '21 13:08 kabircosta

Hi, I think what you want is already available in the Plus version of the Toolkit. If you start the LiveExplorer, available here https://xceed.com/en/our-products/product/toolkit-plus-for-wpf, and you test the sample PropertyGrid/UsingSelectedObjects/Localization, it will show the ExtendedDisplayName attribute from an enum values. The affected enum is ActorWithDisplayName. You can see the code in the Code tab from the LiveExplorer sample.

You can try the Plus version for free for 45 days. Thank you.

XceedBoucherS avatar Aug 27 '21 20:08 XceedBoucherS