This project has moved. For the latest updates, please go here.

[PropretyGrid] Pretend everything is ExpandableObject?

Aug 16, 2013 at 7:34 PM
Is there a way to configure PropertyGrid to pretend everything is an ExpandableObject? I have a use case where the SelectedObject could be almost anything -- I'd rather not apply this attribute to every class in our codebase.

It seems like DescriptorPropertyDefinition is the class that makes this determination, but it's not clear to me if/how I could swap this out for my own inheriting implementation.
Developer
Aug 19, 2013 at 3:27 PM
Hi,

Right now, the PropertyItem has a Dependency Property "IsExpandable" (from PropertyItemBase). When initializing the PropertyItem, the Dependency property is bound to propertyItem.DescriptorDefinition.IsExpandable property.

If "PropertyItemBase.IsExpandable" is set to "True" by default and the binding is canceled, all the properties in the PropertyGrid will be expandables. The binding is currently set in the private method ObjectContainerHelperBase.InitializePropertyItem().

Another option could be top keep the binding, but to make sure the binded Dependency Property is always True. This is done in the internal method "DescriptorPropertyDefinitionBase.UpdateIsExpandable()". This method does 2 checks :
a) Is there an Expandable attribute
b) Is there a value

Unfortunately, these modifications need to be done in internal or private methods. Please create an issue if these options are not solutions for you.
Thanks.
Aug 19, 2013 at 3:31 PM

I already made my own modifications in a local version. I just have added a property to the grid “ForceExpandable”, mirroring the SelectedObject property (in terms of dependency and routing WPF stuff), then passed it down the chain to the appropriate place.

If you’re interested in merging my changes upstream let me know.