Gets or sets a collection of custom editors to use in place of the default editors.
Property Value
A
EditorDefinitionCollection containing
EditorDefinition instances that represent custom editors.
The following shows how to create a PropertyGrid that overrides the default editors with custom editors with a DataTemplate. This is done by defining an EditorDefinition that either targets a Type, property name, or both, and sets the EditorDefinition.EditorTemplate to an instance of a DataTemplate. Be sure to bind your custom editor to the bound property item's Value property.
<xctk:PropertyGrid x:Name="_propertyGrid1" Width="450" Margin="10">
<xctk:PropertyGrid.EditorDefinitions>
<!-- This EditorDefinition will provide a TextBox to any property that is of type HorizontalAlignment, replacing the default ComboBox editor. -->
<xctk:EditorDefinition TargetType="{x:Type HorizontalAlignment}">
<xctk:EditorDefinition.EditorTemplate>
<DataTemplate>
<TextBox Background="Green" Text="{Binding Value}" /> <!-- Always bind your editor's value to the bound property's Value -->
</DataTemplate>
</xctk:EditorDefinition.EditorTemplate>
</xctk:EditorDefinition>
<!-- This EditorDefinition will provide a TextBlock to any property that has any of the defined property names, replacing the default editor. -->
<xctk:EditorDefinition>
<xctk:EditorDefinition.PropertiesDefinitions>
<xctk:PropertyDefinition Name="Age" />
<xctk:PropertyDefinition Name="WritingFont" />
<xctk:PropertyDefinition Name="Spouse" />
</xctk:EditorDefinition.PropertiesDefinitions>
<xctk:EditorDefinition.EditorTemplate>
<DataTemplate>
<TextBlock Background="Yellow" Text="{Binding Value}" />
</DataTemplate>
</xctk:EditorDefinition.EditorTemplate>
</xctk:EditorDefinition>
<!-- This EditorDefinition will provide a TextBox to any property that is of type Boolean or that has any of the defined property names, replacing the default editor. -->
<xctk:EditorDefinition TargetType="{x:Type sys:Boolean}">
<xctk:EditorDefinition.PropertiesDefinitions>
<xctk:PropertyDefinition Name="DateOfBirth" />
<xctk:PropertyDefinition Name="LastName" />
</xctk:EditorDefinition.PropertiesDefinitions>
<xctk:EditorDefinition.EditorTemplate>
<DataTemplate>
<TextBox Background="Red" Text="{Binding Value}" />
</DataTemplate>
</xctk:EditorDefinition.EditorTemplate>
</xctk:EditorDefinition>
</xctk:PropertyGrid.EditorDefinitions>
</xctk:PropertyGrid>
Target Platforms: Windows 11, Windows 10, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2