Xceed Toolkit Plus for WPF v5.1 Documentation
Xceed.Wpf.Toolkit Assembly / Xceed.Wpf.Toolkit.PropertyGrid Namespace / PropertyGrid Class / EditorDefinitions Property
Example


In This Topic
    EditorDefinitions Property (PropertyGrid)
    In This Topic

    Gets or sets a collection of custom editors to use in place of the default editors.

    Syntax
    'Declaration
     
    
    Public Property EditorDefinitions As EditorDefinitionCollection
    'Usage
     
    
    Dim instance As PropertyGrid
    Dim value As EditorDefinitionCollection
     
    instance.EditorDefinitions = value
     
    value = instance.EditorDefinitions
    public EditorDefinitionCollection EditorDefinitions {get; set;}

    Property Value

    An EditorDefinitionCollection containing EditorDefinition instances that represent custom editors.
    Example
    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>
    Supported Frameworks

    .NET: net5.0, net5.0-windows, net6.0, net6.0-macos, net6.0-windows, net7.0, net7.0-macos, net7.0-windows, net8.0, net8.0-browser, net8.0-macos, net8.0-windows, net9.0, net9.0-browser, net9.0-macos, net9.0-windows, net10.0, net10.0-browser, net10.0-macos, net10.0-windows.

    .NET Framework: net40, net403, net45, net451, net452, net46, net461, net462, net463, net47, net471, net472, net48, net481.

    See Also