Version

Configuring Editors Definitions (xamPropertyGrid)

Topic Overview

Purpose

This topic explains how to customize the editors used for editing the properties’ values.

Required background

The following topics are prerequisites to understanding this topic:

Topic Purpose

This topic explains the features supported by the control from developer perspective.

This topic provides an overview of the visual elements of the control.

Editor Definition Configuration Summary

Editor definition configuration summary

The xamPropertyGrid automatically assigns an editing control for each property depending on the property’s type. Read-only properties and read/write properties of the same type are assigned equal editing controls, however the editing controls for the read-only properties are disabled. You can force the xamPropertyGrid to use a different editor control in place of the default editor for any property (or group of properties) by adding a PropertyGridEditorDefinition to the xamPropertyGrid’s EditorDefinitions collection.

You can change the editor assigned to specific properties (or groups of properties) by creating a PropertyGridEditorDefinition that specifies the property category, property name and/or property type whose editor you would like to customize.

Note
Note

By default all properties with custom editors set are not rendered as expandable even if they are eligible to be. If you need to configure a specific property with custom editor as expandable you can set the AllowExpansionWhenUsingCustomEditor property on the associated PropertyGridPropertyItem to true.

Editor definition configuration summary chart

The following table explains briefly the configurable aspects of a PropertyGridEditorDefinition object used to provide property editor customization and maps them to properties.

Configurable aspect Details Property

Target properties by category

Provide a category name to assign the editor to all properties in the specified category.

Target properties by type

Provide a type to assign the editor to all properties of this type.

Target property/properties by name/names

Provide a list of property names to assign the editor to all properties with the specified names.

Set template for editing

Provide a template with control(s) which will be used when editing.

Set template for read-only

Provide a template with control(s) which will be used when a read-only property is displayed.

Note
Note

The data context of the templates is set to an instance of a PropertyGridPropertyItem so that the property value can be accessed by providing a binding with path set to “Value”.

Code Example: Targeting Editor Definition by Property Name

Description

The following code example shows how to define an editor (based on a Slider) for editing the property named "Level".

Code

In XAML:

Code
<ig:XamPropertyGrid>
  <ig:XamPropertyGrid.EditorDefinitions>
    <ig:PropertyGridEditorDefinition>
      <ig:PropertyGridEditorDefinition.TargetProperties>
        <sys:String>Level</sys:String>
      </ig:PropertyGridEditorDefinition.TargetProperties>
      <ig:PropertyGridEditorDefinition.EditTemplate>
        <DataTemplate>
          <Slider Minimum="0" Maximum="10" TickFrequency="1" IsSnapToTickEnabled="True"
            Value="{Binding Value}" />
        </DataTemplate>
      </ig:PropertyGridEditorDefinition.EditTemplate>
    </ig:PropertyGridEditorDefinition>
  </ig:XamPropertyGrid.EditorDefinitions>
</ig:XamPropertyGrid>

Code Example: Targeting Editor Definition by Category and Type

Description

The following code example shows how to define an editor (based on a Slider) for editing all properties of type Int32 in the “Personal” category.

Code

In XAML:

Code
<ig:XamPropertyGrid>
  <ig:XamPropertyGrid.EditorDefinitions>
    <ig:PropertyGridEditorDefinition Category="Personal" TargetType={x:Type sys:Int32}>
      <ig:PropertyGridEditorDefinition.EditTemplate>
        <DataTemplate>
          <Slider Minimum="0" Maximum="10" TickFrequency="1" IsSnapToTickEnabled="True"
            Value="{Binding Value}" />
        </DataTemplate>
      </ig:PropertyGridEditorDefinition.EditTemplate>
    </ig:PropertyGridEditorDefinition>
  </ig:XamPropertyGrid.EditorDefinitions>
</ig:XamPropertyGrid>
Note
Note

You can target your editor definition by type or category only.

Related Content

Topics

The following topics provide additional information related to this topic.

Topic Purpose

This topic explains how to configure some general control options.

This topic explains how to configure the filtering of the control’s properties list.

This topic explains how to provide logic for custom sorting of the properties list.

This topic explains how create custom logic for assigning editing template on an editor definition.