How to hide Inherited Properties

Jan 6, 2011 at 3:46 PM

Hi,

I am using your project explorer with classes that extend DependencyObject,. So as well as my own properties all the DependencyObject properties are also shown. Is there a way that I can hide these and only show the properties I have defined in my own class?  Great software by the way well done.

Thanks

Alan

Coordinator
Jan 7, 2011 at 6:27 AM

hi Alan,

I had the same problem with dependency properties, and have not found a good solution yet..

The "DeclaredOnly" property was intended to hide all inherited properties, and it was working well until I changed to TypeDescriptor.GetProperties(...) in the PropertyEditor.CreatePropertyModel.

Maybe the PropertyDescriptors can be compared with PropertyInfos to figure out if it is an inherited property?

Also see the "RequiredAttribute" property, this can filter all properties that do not have the specified attribute set.

Let us know if you find a better solution to this!

Jan 7, 2011 at 3:05 PM
objo wrote:
Also see the "RequiredAttribute" property, this can filter all properties that do not have the specified attribute set.

Hi objo,

I am very new to wpf so do not understand your comment above. I would appreciate some example of its use.

Thanks Alan

Jan 7, 2011 at 3:24 PM

Ok, so tried

 

 wpfPropertyGrid1.RequiredAttribute = typeof(System.ComponentModel.BrowsableAttribute);

 

and it seems to work fine. So thanks

 

Alan

Coordinator
Jan 8, 2011 at 6:32 AM

hi Alan, 

yes, that should work. You can also define your own attribute class. And you could write it in XAML: 

<p:PropertyEditor ... RequiredAttribute="{x:Type m:MyAttribute}">