PropertyGrid: Customize editors globaly

Grids for WPF Forum

Posted 29 days ago by BenjaminLopVic - France
Version: 24.1.1
Avatar

Hello,

In my PropertyGrid, I want to set "UseDisplayAttributes" to true for all my all my enum editors.

Currently, I'm using this code:

<grids:PropertyEditor PropertyType="sys:Enum">
    <grids:PropertyEditor.ValueTemplate>
        <DataTemplate>
            <editors:EnumEditBox Value="{Binding Value}" UseDisplayAttributes="True" />
        </DataTemplate>
    </grids:PropertyEditor.ValueTemplate>
</grids:PropertyEditor>

It does the job except when I use nullable enums, the editor no longer uses the "Description" attribute.

So i tried :

PropertyType="{shared:Nullable {x:Type sys:Enum}}"

But i get a TypeLoadException : GenericArguments[0], 'System.Enum', on 'System.Nullable`1[T]' violates the constraint of type 'T'.

Currently, on nullable enums, I'm using the following code, but I need to do it for each enum I want to use:

PropertyType="{shared:Nullable {x:Type mysNamespace:MyEnum}}"

Is there a better solution to force "UseDisplayAttributes" on all my EnumEditBox of my PropertyGrid ? 

Thanks.

Benjamin.

Comments (2)

Answer - Posted 29 days ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

The /ProductSamples/GridsSamples/QuickStart/PropertyGridEditorsIntegration/MainControl.xaml file in our samples project shows an example of adding EnumPropertyEditor with UseDisplayAttributes set.  I wonder if doing that instead would work for your scenario instead of what you are currently doing.


Actipro Software Support

Posted 28 days ago by BenjaminLopVic - France
Avatar

Hello,

Thank you, that's exactly what I was looking for.

Best regards.

 
The latest build of this product (v24.1.2) was released 7 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.