Descriptions
- 3 minutes to read
Overview
The PropertyGrid control can display extra information about the properties of a bound object in the form of property descriptions. You can specify property descriptions in the following ways.
- At the control level, using the PropertyDefinitionBase.Description property.
- At the model level, using the Description attribute.
Depending on the PropertyGridControl.ShowDescriptionIn property value, the property grid displays property descriptions in the following ways.
ShowDescriptionIn property value | Property descriptions position |
---|---|
None | Descriptions are disabled. |
Panel | The description panel. |
ToolTip | A description tooltip. |
ToolTipAndPanel | Both the description panel and description tooltip. |
Specifying Property Descriptions at the Control Level
The PropertyGrid control allows you to specify a custom description for each of the following elements.
- Properties
- Collections
- Category rows
Descriptions are specified for individual definitions by the PropertyDefinitionBase.Description property. This approach allows you to assign property descriptions by using the association criteria described in the Property Definitions topic.
The example below demonstrates a property grid configured in the following way.
- Both the description panel and the tooltip display the description text.
- All string properties have similar description specified.
- Nested Address property definitions override the description text.
<Window.DataContext>
<local:ViewModel/>
</Window.DataContext>
...
<dxprg:PropertyGridControl SelectedObject="{Binding Data}" ShowProperties="WithPropertyDefinitions" ShowDescriptionIn="ToolTipAndPanel">
<dxprg:PropertyDefinition Type="sys:String" Description="A string property"/>
<dxprg:PropertyDefinition Type="{x:Type local:SimpleAddress}" Description="Customer's address">
<dxprg:PropertyDefinition Path="*" Description="Address details"/>
<dxprg:PropertyDefinition Path="ZIP" Description="Customer's postal code"/>
</dxprg:PropertyDefinition>
</dxprg:PropertyGridControl>
Note
To learn more about nested properties, refer to the Nested properties section of the Property Definitions topic.
Specifying Property Descriptions at the Model Level
To specify property descriptions at the model level, use the Description attribute.
The Description attribute allows you to specify descriptions for the following elements.
- Properties
- Collections
Note
Descriptions specified by the PropertyDefinitionBase.Description property override the description attribute values.
Note
To learn more about the property attributes supported by the PropertyGrid control, see Property Attributes.
The following example demonstrates the property descriptions defined with the Description attribute.
<Window.DataContext>
<local:ViewModel/>
</Window.DataContext>
...
<dxprg:PropertyGridControl SelectedObject="{Binding Data}" ShowProperties="WithPropertyDefinitions" ShowDescriptionIn="ToolTipAndPanel">
<dxprg:PropertyDefinition Type="sys:String" />
<dxprg:PropertyDefinition Type="{x:Type local:SimpleAddress}" >
<dxprg:PropertyDefinition Path="*" />
<dxprg:PropertyDefinition Path="ZIP"/>
</dxprg:PropertyDefinition>
</dxprg:PropertyGridControl>