The PropertyGrid control allows you inspect and edit properties of an object. This PropertyGrid allows you to autogenerate all properties or specify the specific properties you want to display. You can use the standard editors that are provided with the PropertyGrid or you can use custom editors that target a Type, specific properties, or both. The PropertyGrid also supports complex properties, which allows you to drill down into a nested property hierarchy.
By default the propertyGrid will autogenerate all the properties for a given object. You can override this behavior by setting the AutoGenerateProperties property to False, and then provide a collection of PropertyDefinitions of the properties you would like to show.
By default the PropertyGrid comes with 19 built-in editors:
* ByteUpDownEditor
@ -52,14 +52,14 @@ By default the PropertyGrid comes with 19 built-in editors:
* TextBlockEditor
* TextBoxEditor
* TimeSpanEditor
{anchor:custom_editors_dataTempates}
**Custom Editors with DataTemplates**
### Custom Editors with DataTemplates
You can override the default editors with your own custom editors with a DataTemplate. Simply define an EditorDefinition that either targets a Type, property name, or both and set the EditorDefinition.EditorTemplate to an instance of a DataTemplate. Be sure to bind your custom editor to the bound property item's Value property.
@ -138,15 +138,15 @@ You can override the default editors with your own custom editors with a DataTem
</xctk:PropertyGrid.EditorDefinitions>
</xctk:PropertyGrid>
}}
{anchor:custom_editors_attributes}
**Custom Editors with Attributes**
```
### Custom Editors with Attributes
You can supply editors for a property by using the System.ComponentModel.EditorAttribute. In order to provide an editor with an attribute, the editor MUST implement the ITypeEditor interface. Your editor can be a simple class or a complex UserControl.
public partial class LastNameUserControlEditor : UserControl, ITypeEditor
{
public LastNameUserControlEditor()
@ -232,14 +232,14 @@ Using a UserControl:
return this;
}
}
}}
{anchor:custom_itemssource}
## Custom ItemsSource
```
### Custom ItemsSource
Sometimes it is desirable to want to provide a collection of values represented by a ComboBox for a given property. The PropertyGrid supports this scenario by creating a class that implements the IItemsSource interface and decorating your property with the ItemsSourceAttribute.

[[PropertyGrid_custom_itemssource.jpg]]
{{
```
public class Person
{
[Category("Writing")](Category(_Writing_))
@ -248,10 +248,10 @@ Sometimes it is desirable to want to provide a collection of values represented
@ -276,14 +276,14 @@ The custom ItemsSource class:
return sizes;
}
}
}}
{anchor:expandable_properties}
## Expandable Properties
```
### Expandable Properties
Sometimes it is neccessary to show the properties of a complex object. The PropertyGrid supports this scenario and allows you to drill down into a property's heirarchy. To enable this behavior you must decorate your property with the ExpandableObject attribute.
@ -296,43 +296,45 @@ Sometimes it is neccessary to show the properties of a complex object. The Prop
[ExpandableObject](ExpandableObject)
public Person Spouse { get; set; }
}
}}
## Properties
|| Property || Description
| AdvancedOptionsMenu | Gets/Sets the contextual menu to use when the advanced menu button is clicked.
| AutoGenerateProperties | Get/Sets if the propertyGrid should generate all properties for a given object. If False you must provide PropertyDefinitions for the properties you want to generate.
| EditorDefinitions| Get/Sets a collection of custom editors to use in place of the default editors. (Breaking change as of v1.6.0: previously was CustomTypeEditors.)
| Filter | Gets/Sets the filter used to filter the visible properties in the PropertyGrid.
| FilterWatermark | Gets/Sets the watermark used in the filter field.
| HideInheritedProperties | Gets or sets if the Inherited properties of the selected object will be hidden. Default is False.
| IsCategorized | Gets/Sets the layout of the PropertyGrid.
| IsReadOnly | Gets or sets a value indicating whether the property grid is read-only.
| NameColumnWidth | Gets/Sets the width of the property name column.
| Properties | Gets the current collection of generated PropertyItems.
| PropertyDefinitions | When **AutoGenerateProperties** = False, gets/sets the properties that will be generated by the PropertyGrid
| SelectedObject | Gets/Sets the current object the PropertyGrid is inspecting,
| SelectedObjectName | Gets/Sets the **SelectedObject** name.
| SelectedObjectType | Gets/Sets the Type of the **SelectedObject**.
| SelectedObjectTypeName | Gets/Sets the name of the Type of the **SelectedObject**.
| SelectedProperty | Gets or sets the selected property or returns null if the selection is empty.
| SelectedPropertyItem | Gets the currently selected PropertyItem
| ShowAdvancedOptions | Gets/Sets the visibility of the advanced options button next to the properties.
| ShowPreview | Gets or sets if the preview of the control is displayed
| ShowDescriptionByTooltip | Gets/Sets if the Description of the PropertyItem will be displayed as a tooltip on the PART_Name of the PropertyItem. When ShowDescriptionByTooltip is True and the DescriptionAttribute on the PropertyItem is not null and not empty, it will be displayed as a tooltip.
| ShowSearchBox | Gets/Sets a value indicating whether the search box is displayed. By default, true.
| ShowSortOptions | Gets/Sets a value indicating whether the show sort options are displayed (Categorized and Alphabetical). By default, true.
| ShowSummary | Gets or sets a value indicating whether the summary pane is shown.
| ShowTitle | Gets or sets a value indicating whether the PropertyGrid's title is displayed.
| UpdateTextBoxSourceOnEnterKey | Gets or sets if the source of the propertItem represented by a TextBox will be updated when Enter key is pressed.
## Events
|| Event || Description
| ClearPropertyItem | This event is raised when an property item is about to be remove from the display in the PropertyGrid. This allow the user to remove any attached handler in the PreparePropertyItem event.
| PreparePropertyItem | This event is raised when a property item is about to be displayed in the PropertyGrid. This allow the user to customize the property item just before it is displayed.
| PropertyValueChanged | Raised when a property's value changes.
| SelectedObjectChanged | Raised when SelectedObject changes.
| SelectedPropertyItemChanged | Raised when SelectedProperty changes.
**Support this project, check out the [Plus Edition](https://xceed.com/xceed-toolkit-plus-for-wpf/).**
---
```
### Properties
| Property | Description |
| --- | --- |
| AdvancedOptionsMenu | Gets or sets the contextual menu to use when the advanced menu button is clicked. |
| AutoGenerateProperties | Get or sets if the propertyGrid should generate all properties for a given object. If False you must provide PropertyDefinitions for the properties you want to generate. |
| EditorDefinitions| Gets or sets a collection of custom editors to use in place of the default editors. (Breaking change as of v1.6.0: previously was CustomTypeEditors.) |
| Filter | Gets or sets the filter used to filter the visible properties in the PropertyGrid. |
| FilterWatermark | Gets or sets the watermark used in the filter field. |
| HideInheritedProperties | Gets or sets if the Inherited properties of the selected object will be hidden. Default is False. |
| IsCategorized | Gets or sets the layout of the PropertyGrid. |
| IsReadOnly | Gets or sets a value indicating whether the property grid is read-only. |
| NameColumnWidth | Gets or sets the width of the property name column. |
| Properties | Gets the current collection of generated PropertyItems. |
| PropertyDefinitions | When **AutoGenerateProperties** = False, gets or sets the properties that will be generated by the PropertyGrid. |
| SelectedObject | Gets or sets the current object the PropertyGrid is inspecting. |
| SelectedObjectName | Gets or sets the **SelectedObject** name. |
| SelectedObjectType | Gets or sets the Type of the **SelectedObject**. |
| SelectedObjectTypeName | Gets or sets the name of the Type of the **SelectedObject**. |
| SelectedProperty | Gets or sets the selected property or returns null if the selection is empty. |
| SelectedPropertyItem | Gets the currently selected PropertyItem. |
| ShowAdvancedOptions | Gets or sets the visibility of the advanced options button next to the properties. |
| ShowPreview | Gets or sets if the preview of the control is displayed. |
| ShowDescriptionByTooltip | Gets or sets if the Description of the PropertyItem will be displayed as a tooltip on the PART_Name of the PropertyItem. When ShowDescriptionByTooltip is True and the DescriptionAttribute on the PropertyItem is not null and not empty, it will be displayed as a tooltip. |
| ShowSearchBox | Gets or sets a value indicating whether the search box is displayed. By default, true. |
| ShowSortOptions | Gets or sets a value indicating whether the show sort options are displayed (Categorized and Alphabetical). By default, true. |
| ShowSummary | Gets or sets a value indicating whether the summary pane is shown. |
| ShowTitle | Gets or sets a value indicating whether the PropertyGrid's title is displayed. |
| UpdateTextBoxSourceOnEnterKey | Gets or sets if the source of the propertItem represented by a TextBox will be updated when Enter key is pressed. |
### Events
| Event | Description |
| --- | --- |
| ClearPropertyItem | This event is raised when an property item is about to be remove from the display in the PropertyGrid. This allow the user to remove any attached handler in the PreparePropertyItem event. |
| PreparePropertyItem | This event is raised when a property item is about to be displayed in the PropertyGrid. This allow the user to customize the property item just before it is displayed. |
| PropertyValueChanged | Raised when a property's value changes. |
| SelectedObjectChanged | Raised when SelectedObject changes. |
| SelectedPropertyItemChanged | Raised when SelectedProperty changes. |
---
**Support this project, check out the [Plus Edition](https://xceed.com/xceed-toolkit-plus-for-wpf/).**