I am working with the propertyGrid from Xceed WPF tookit property grid.
When I bind an object to the grid, it lists the nested classes within it using the ToString() method and is read-only. I would like it to also list the properties within these nested classes. Does property grid support this? Is there a better library for this?
e.g.
Class Parameters {
public int number {get;set;}
Public CustomVector vector1 {get; set;}
Public CustomVector vector2 {get; set;}
}
Class CustomerVector {
public double a {get; set;}
public double b {get; set;}
public double c {get; set;}
public double d {get; set;}
}
In this case it would just list 3 elements, returning the ToString() for vector1 and vector2. I would like it to let me edit a,b,c,d of both vectors.
here you go
<xctk:PropertyGrid SelectedObject="{Binding Parameters}">
<xctk:PropertyGrid.PropertyDefinitions>
<xctk:PropertyDefinition Name="number" />
<xctk:PropertyDefinition Name="vector1"
IsExpandable="true" />
<xctk:PropertyDefinition Name="vector2"
IsExpandable="true" />
</xctk:PropertyGrid.PropertyDefinitions>
</xctk:PropertyGrid>
IsExpandable="true"
enables the property editor to expand to sub properties
also you can customize the display value of root (vector1, vector2) by overriding ToString()
method in CustomerVector
class
eg
public override string ToString()
{
return string.Format("{0}, {1}, {2}, {3}", a, b, c, d);
}
result