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

PropertyGrid - How to control display of visible properties at runtime

Dec 27, 2012 at 9:24 PM
Edited Dec 27, 2012 at 9:27 PM

I have various Classes in my project, for which at runtime I want to display their properties.

They are all derived from one base-class at the top of the chain, which has a Property which instances of the subclasses can set at runtime.

What I would like to be able to do is, based on this Property (an enum), is to change WHICH properties of the subclass become 'visible' by the property grid.

Can this be done? I know of the PropertyDefinitions property of the propertygrid itself, and I have played with it, but it does not seem elegent that my object having to return a PropertyDefinitions collection based on my Enum property, when I dont want my objects having to know about PropertyDefinitions, know what I mean?

Can this be acheived in the xaml, via some funky binding or template, instead of having to put this sort of stuff in the code?

Or at least some way (using attributes), to mark the properties of my classes as visible=true/false based on the value of another property of the class?