Show properties of a derived class

Grids for WPF Forum

Posted 12 years ago by Max Palmer
Version: 11.2.0550
I'm trying to solve a problem. I have a property grid that is showing the properties of an object in our view model. One of these properties is initially null. In the editor for the property, the user can choose from a number of class types that derive from a base type (the property type). When the user selects the derived type they want, we create an object of the derived type and then set the property value for the data accessor to the new property value.

The problem is that the data accessor type is set to the base type (which it gets from the object), so we only see the base class properties for the new object in the property grid. The ValueType field on PropertyGridDataAccessorItem is readonly, so it can't be changed to be the derived type. How can I update the PropertyGridDataAccessorItem passed in to class so it shows the property value for the derived type we assign? Can I set/call something on it to update or alternatively replace it with a new PropertyGridDataAccessorItem that for the derived type?



Comments (2)

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

The property type should not really matter. Ultimately it's the TypeDescriptor returned for a given type that determines the child properties. But, if you can please put together a small sample project that reproduces your issue and email it over then we can take a closer look. Be sure to remove any executables or change the extension of the zip file to ensure it gets past our email filters.

Actipro Software Support

Posted 12 years ago by Max Palmer
Thanks, after some tinkering around I fixed it. It was a problem with the underlying data not being the correct type (but in our code).
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.