How do I implement merge logic for an object that implements ICustomTypeDescriptor?

Grids for WPF Forum

Posted 12 years ago by Mick
Version: 12.2.0570

I am trying to make the property grid dynamically show / hide properties depending on the columns that are visibile/collapsed in a grid in my software.

To do so, I have implemented ICustomTypeDescriptor to expose a list of PropertyDescriptor objects, each of which has different EditorAttribute attributes applied depending on the property type.

When I show a simple data type in the property editor (i.e. bool, int, DateTime, string, etc.), the logic that "merges" two selections in the property grid displays the properties as expected. However, when I have 2 "rich" objects, they don't merge at all (the merging logic always returns null).

As an attempt, I implemented IComparable, IComparable<T>, and IEquatable<T> on my object type (the one being selected) and overrode Equals(object obj) on my implementation of the PropertyDescriptor used to display my properties (which never actually gets hit) to no avail.

What do I need to do to implement custom merging logic for the property grid for rich object types?

Comments (1)

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

Hi Mick,

Make sure you override the plain old Equals method on the property value object type too.  You mentioned the other interfaces but not that.  See if that helps.

Actipro Software Support

The latest build of this product (v24.1.2) 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.