When I load PropertyGrid, I want to expand all the propertyitems by default.
In version 2.0, this behavior was there.
In version 2.4, all the property items are collapsed.
I tried expanding it through code, but its not working
```
public void ExpandPropertyGrid()
{
if (customerPropertyGrid.Properties == null)
return;
foreach (var property in customerPropertyGrid.Properties)
{
if ((property as PropertyItem).IsExpandable)
{
(property as PropertyItem).IsExpanded = true;
ExpandProperty((property as PropertyItem));
}
}
}
public void ExpandProperty(PropertyItem property)
{
if (property.Properties == null)
return;
foreach (var element in property.Properties)
{
(element as PropertyItem).IsExpanded = true;
ExpandProperty((element as PropertyItem));
}
}
}
```
Let me know how to expand all items.
Regards,
Sharda.
Comments: ** Comment from web user: BoucherS **
Hi,
After trying the sample "PropertyGrid/UsingAttributes" from the "LiveExplorer App", available here : "https://wpftoolkit.codeplex.com/", I can see that the PropertyItem "Spouse" is collapsed at loading in v2.0 and v2.4. for the Community and Plus users.
If you have the Plus version, you can use the following attribute before your Property to set it expanded at loading :
```
[ExpandableObject( true )]
```
Your code should work :
```
public MainWindow()
{
InitializeComponent();
_propertyGrid.SelectedObject = new MyData()
{
Name = "TESTING",
MyClass = new MyClass()
{
MyInt = 35,
MyString = "AAAA"
}
};
foreach( var property in _propertyGrid.Properties )
{
if( (property as PropertyItem).IsExpandable )
{
(property as PropertyItem).IsExpanded = true;
}
}
}
```