Expandability Customization
- 3 minutes to read
Overview
The PropertyGrid control allows you to customize property expandability in the following ways.
- At the control level, using the AllowExpanding property.
- At the model level, using the TypeConverter attribute.
Customizing Property Expandability at the Control Level
The following PropertyGrid properties affect the expandability behavior.
- PropertyGridControl.AllowExpanding specifies the expandability behavior for the entire property grid.
- PropertyDefinition.AllowExpanding specifies the expandability behavior for individual properties.
Note
The PropertyDefinition.AllowExpanding property has higher precedence than the PropertyGridControl.AllowExpanding property.
The following table lists the available AllowExpanding property values and corresponding expandability modes.
AllowExpanding property value | Property grid expandability behavior |
---|---|
Default | Expands properties according to their type converters. |
Force | Expands all properties. |
ForceIfNoTypeConverter | Expands all properties that don’t have a type converter. |
Never | Properties are not expandable. |
The following example demonstrates the AllowExpanding property precedence.
<Window.DataContext>
<local:ViewModel/>
</Window.DataContext>
...
<dxprg:PropertyGridControl Grid.Column="1" SelectedObject="{Binding Data}" ShowProperties="All" AllowExpanding="Force">
<dxprg:PropertyDefinition Path="PublicInfo"/>
<dxprg:CollectionDefinition Path="PrivateInfo" AllowExpanding="Never"/>
</dxprg:PropertyGridControl>
Customizing Property Expandability at the Model Level
To control property expandability from the model, use the TypeConverter attribute.
Important
A type converter affects the expandability if the AllowExpanding property is set to Default or ForceIfNoTypeConverter.
Note
To learn more about the property attributes supported by the PropertyGrid control, see Property Attributes.
<Window.DataContext>
<local:ViewModel/>
</Window.DataContext>
...
<dxprg:PropertyGridControl Grid.Column="1" SelectedObject="{Binding Data}" ShowProperties="All" AllowExpanding="Default">
<!--No type converter, not expandable-->
<dxprg:PropertyDefinition Path="Simple"/>
<dxprg:PropertyDefinition Path="Expandable"/>
<dxprg:PropertyDefinition Path="NotExpandable"/>
<!--No type converter, expandable-->
<dxprg:CollectionDefinition Path="Collection"/>
</dxprg:PropertyGridControl>