Complex Object displaying the class hierarchy(Namespace)

Feb 27, 2012 at 4:05 AM


                 I am using the WPF Extended PropertyGird control. I am displaying the properties of a Complex Object by using the [ExpandableObject] attribute. When i display these properties, propertyGrid displays the full NameSpace of the Complex class. Is there any way to hide this from end user as in most of cases enduser dont need to known of the internal class hierarchy. I want to display the ComplexObject similar to a Category with 'n' number of child elements with no value (blank in place of NameSpace) associated to the root element.



Mar 12, 2012 at 11:40 AM

Is the above behaviour supported in the present version (or) do you have any plans to include this in future versions ?..thanks

Mar 12, 2012 at 2:39 PM

What I am describing here is for the version 1.6.0 which will be release shortly.


Your complex class full namespace is displayed because it is the intended behavior of the editor associated to your complex object.  The section next to the property name is the editor of that property.  I assume you don't have a custom editor defined for your complex class.  If no custom editor is set, the PropertyGrid will try one of the default ones.  In this case, it will pick a TextBlockEditor.  That editor will bind the underlying TextBlock to your ComplexObject, which will indirectly call your {ComplexObject}.ToString() method.  The ToString method's default behavior is to return the object's full namespace.


If you want to hide the full namespace of your complex class, you may try one of the following:

  1. Override the objet.ToString() method in your complex class and make it return what you want.
  2. Defined your own custom editor for your complex class that won't do or display anything.


Here is an example of a custom editor that could be used for your complex class and how you may set it on your property:

public class MyComplexEditor : Microsoft.Windows.Controls.PropertyGrid.Editors.ITypeEditor
  public FrameworkElement ResolveEditor( Microsoft.Windows.Controls.PropertyGrid.PropertyItem propertyItem )
    // This TextBlock will display nothing since it is not bound to anything.
    return new TextBlock();

// Here is your complex class.
public class MyClass

  [Editor( typeof( MyComplexEditor ), typeof( MyComplexEditor )]
  public ComplexClass MyComplexProperty 




Mar 16, 2012 at 8:58 AM

Thanks a lot  for the solution !!