Custom editor for objects in an array

Grids for WPF Forum

Posted 4 years ago by Justin Klein
Version: 15.1.0623
Avatar

When populating a PropertyGrid via SelectedObject, my understanding is that the correct way to specify my desired editor for a given property is to mark it with the Editor attribute, i.e.:

using ActiproSoftware.Windows.Controls.PropertyGrid.Editors;
 
[Editor(typeof(ComboBoxPropertyEditor), typeof(PropertyEditor))]
public bool TestValue { get; set; } 

 

That works fine - however, how would I specify the editor for objects contained in an array property?  For instance:

using ActiproSoftware.Windows.Controls.PropertyGrid.Editors;

bool[] testValue = new bool[20];

[Editor(typeof(ComboBoxPropertyEditor), typeof(PropertyEditor))]
public bool[] TestValue { get { return testValue; } set{ testValue=value; } }

 This will show a ComboBox on the PropertyGrid line listing the name of the array itself - whereas I'm trying to get a ComboBox for each boolean within the array?

Comments (2)

Posted 4 years ago by Justin Klein
Avatar

Found a workaround: I just set a PropertyEditor that applies to all properties of type bool (including those in the array).  This isn't an explicit per-property specification (as above), but actually works better in my case.  i.e.:

<ActiPropGrid:PropertyGrid.PropertyEditors>
    <ActiPropGrid:PropertyEditor PropertyType="{x:Type system:Boolean}">
        <ActiPropGrid:PropertyEditor.ValueTemplate>
            <DataTemplate>
                ...
            </DataTemplate>
        </ActiPropGrid:PropertyEditor.ValueTemplate>
    </ActiPropGrid:PropertyEditor>
</ActiPropGrid:PropertyGrid.PropertyEditors>
Posted 4 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Justin,

The workaround you are doing is what we should suggest.  I don't think there is another way to specify the property editor for array items.


Actipro Software Support

The latest build of this product (v2019.1 build 0683) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.