Henrik Berg
Henrik Berg

Reputation: 549

WPF Extended Toolkit PropertyGrid - Expand all properties by default

I am using the PropertyGrid from the Xceed WPF Extended Toolkit. Is there a way that I can make all properties expanded by default? Actually, I'll never need them to be "unexpanded" ever, so if the "un-expansion" (is there a word for that, BTW?) could be disabled, that would be even better.

Upvotes: 1

Views: 2118

Answers (3)

uzrgm
uzrgm

Reputation: 395

_propertyGrid.ExpandAllProperties();

Upvotes: 0

Andrey the Autobot
Andrey the Autobot

Reputation: 121

If you set IsCategorized="False" you will see all properties expanded by default:

<xceed:PropertyGrid IsCategorized="False" SelectedObject="{Binding}"/>

Also you can specify

ShowPreview="False" ShowSearchBox="False" ShowSortOptions="False"
ShowSummary="False" ShowTitle="False" ShowAdvancedOptions="False"

to disable all other parts than main property editor grid.

Upvotes: 0

Bradley Uffner
Bradley Uffner

Reputation: 16991

If you are still looking for a way to do this, I just figured it out myself.

private void PropertyGrid_SelectedObjectChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
{
    var grid = sender as PropertyGrid;

    foreach (PropertyItem prop in grid.Properties)
    {
        if (prop.IsExpandable) //Only expand things marked as Expandable, otherwise it will expand everything possible, such as strings, which you probably don't want.
        {
            prop.IsExpanded = true; //This will expand the property.
            prop.IsExpandable = false; //This will remove the ability to toggle the expanded state.
        }
    }
}

Upvotes: 2

Related Questions