Collections and CollectionDisplayMode

Grids for WPF Forum

Posted 8 years ago by Tarquin
Version: 11.2.0552
Avatar

I have two collections being represented in my property grid. I am trying to represent the two collections in the property grid differently. The one I want to represent with the "Default" collectionDisplayMode and the other I want to display with the  "EditableInline" CollectionDisplayMode.

 

Is there any way I can achieve this?

 

Thanks in advance

Comments (3)

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

Hi Tarquin,

The only way to accomplish that would be with a custom implicit Style for the PropertyGridDataAccessorItem type (which is our equivalent of a TreeViewItem). You would need to use a Style trigger like so:

<MultiDataTrigger> 
    <MultiDataTrigger.Conditions> 
        <Condition Binding="{Binding DataAccessorType, RelativeSource={RelativeSource Self}}" Value="Property" /> 
        <Condition Binding="{Binding DisplayName, RelativeSource={RelativeSource Self}}" Value="MyEditableCollection" /> 
    </MultiDataTrigger.Conditions> 
    <Setter Property="propgrid:PropertyGrid.CollectionDisplayMode" Value="EditableInline" /> 
</MultiDataTrigger>


Actipro Software Support

Posted 8 years ago by Tarquin
Avatar

Thanks for your reply.

Can I ask this question another way. What if I had a very specialised property such as an airplane seating position and I wanted to drop down a selectable seating diagram when a user wants to set the property value.

How would I:

1) Link this property editor to the property

2) Have access to the property value in the property editor

3) Commit the value, etc.

In windows forms this is done using editor attributes and developing a custom property editor class. How would I do something similar for your property grid.

 

Thanks for your help.

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

Hi Tarquin,

We have samples that show how this can be accomplished. The Editors Integration (Custom) demo shows how you can leverage the EditorAttribute as you did in the WinFroms PropertyGrid. Effectively you create a class that derives from our PropertyEditor and indicates which DataTemplate should be used to present the property's value. The DataTemplate can contain any WPF supported content.

The samples show how to bind to the associated value also, but looks like:

{Binding Value, RelativeSource={RelativeSource AncestorType={x:Type propgrid:IPropertyDataAccessor}}, Mode=TwoWay}

Values are committed using WPF bindings, but you could write custom code to programmatically set the Value using similar logic.

You can also map PropertyEditors to properties by property name, property type, object type, or any combination of those. This is done on the PropertyGrid (for a single instance) or our BuiltinEditors class (for all PropertyGrids), and allows you to keep the UI logic out of your data objects.

There are several other ways to specify the editor that can be used, but those are the two most common.


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.