EnumPropertyEditor and controlling EnumListBoxDisplayMode

Editors for WPF Forum

Posted 6 years ago by Wiley Knoch
Version: 16.1.0635

I am using the EnumPropertyEditor to display some enum values to pick from in a property grid.  It is fantastically designed to support switching between CheckBox & RadioButton display modes based on whether the enum has the Flags attribute implemented.  My issue is that I need to conditionally change the display mode from CheckBox to RadioButton for a enum that has the flags attribute and cannot figure out how to properly do this.

Since I will need to conditionally do this for specific scenarios I created my own custom class that inherits EnumPropertyEditor that I use to control the display mode:

public class MyEnumPropertyEditor : EnumPropertyEditor
   public MyEnumPropertyEditor()
      // How do I change the display mode for the EnumListBox that will be created for this editor instance?

[DisplayName("Some Display")]
[Editor(typeof(MyEnumPropertyEditor), typeof(UITypeEditor))]
public EnumWithFlags SomeEnumProperty { get; set; }

Any help in solving this would be appreciated.

Comments (2)

Answer - Posted 6 years ago by Actipro Software Support - Cleveland, OH, USA

Hi Wiley,

We're glad you like the EnumEditBox.  Unfortunately there isn't a way to dynamically switch between flags and non-flags modes.  It determines that pretty deeply in the code (in EnumListBox) based on the presence of the Flags attribute.

Is it possible for you to clone the Flags-based enum and name it without the plural enum name, also excluding the Flags attribute on it?  Then you'd have two enums with the same values but one is flags and one is not.  That is effectively what we do in our sample too and works great.

Actipro Software Support

Posted 6 years ago by Wiley Knoch

Kind of what I figured and even though I don't like the duplication, creating 2 enums is easy enough.  Thanks.

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

Add Comment

Please log in to a validated account to post comments.