Skip to content
This repository has been archived by the owner on Apr 9, 2020. It is now read-only.

Editors

DenisVuyka edited this page Feb 27, 2011 · 1 revision

Editors

An editor is a component that provides a value editing service for each property grid component. Value editors are responsible for providing rich user experience for managing object's properties, simplifies values input and provides validation facilities in order keep object data safe and consistent.

You will need to know about editors to accomplish the following scenarios:

  • Provide a custom editor that allows editing a particular property or type of property (for example a color selector or datetime picker)
  • Provide a custom editor for the whole category of properties
  • Replace a built-in editor with brand new implementation
  • Customize the look and feel of existing built-in or 3rd party editor

WPF Property Grid introduces the following types of editors:

  • Type Editors that allow editing type of property (for example all string-based properties or all boolean-based ones)
  • Property Editors that allow editing a particular property of a type (for example "Name" property of the type "User")
  • Category Editors that allow editing the whole category of properties (for example "Text" category in "Control" type)

Current version provides built-in editors for the following types of values:

  • System.Boolean
  • System.Enum
  • System.String
  • System.Windows.FontStretch
  • System.Windows.FontStyle
  • System.Windows.FontWeight
  • System.Windows.Input.Cursor
  • System.Windows.Media.Brush
  • System.Windows.Media.FontFamily

The rest of the types are covered by a default string-based editor.

Additionally current version provides a set of optional editors that are not bound to property types by default but can be reused in specific scenarios. Among them are:

  • Password Editor, allows using a PasswordBox control for string-based properties
  • Double Editor, allows editing System.Double values in the Expression Blend fashion when the value can be assigned either via keyboard input or mouse gestures
  • Slider Editor, allows editing ranged values with a slider so increasing user experience and restricting from entering invalid data

Note: Next versions of Property Grid will provide more built-in support for common and widely used types.

Editor Structure


All editors inherit the base abstract Editor type. This is a Dependency Object that can be used in XAML-only scenarios and exposes all the API required to introduce derived Type, Property and Category editors.

InlineTemplate (dependency property)

Specifies a template for the editor that should be used within the property grid control to edit a value. The value for this property can be either a DataTemplate object that describes a visual structure of the editor or ComponentResourceKey object that defines a resource reference for a visual structure of the editor (usually a DataTemplate contained within resource dictionary).

This is a mandatory template for all types of editors.

ExtendedTemplate (dependency property)

Specifies a template for the editor that should be used for advanced scenarios of property value editing. Alongside with inline editing of the property value property grid allows you opening an advanced version of the same editor in a separate Tab that can be left open of closed when there is no need in it. The value for this property can also be either a DataTemplate or a ComponentResourceKey pointing to the proper editor template.

Note: Extended templates are supported only when property grid is configured to use Tabbed Layout.

Usually extended editor support is presented by additional "ellipsis" button or some other UI element within the inline editor template. It is possible to intercept the call to show extended editor for a property by owning application and perform additional tasks.

DialogTemplate (dependency property)

Specifies a template for the editor that should be opened in a separate dialog. The value for this property can also be either a DataTemplate or a ComponentResourceKey pointing to the proper editor template.

This property is reserved to external implementations. It is possible to intercept the call to show dialog editor inside owning application and provide all necessary steps in editing the value of the property.