In This Article

PropertyGrid

The controls provided in the Editors product can be easily integrated into the PropertyGrid control, through the use of custom property editors. In order to keep both products segregated, an Interop assembly is provided that ties the two products together.

Screenshot

PropertyGrid with BrushEditBox integrated

Interop Assembly

The Interop functionality is provided through a separate assembly, which is called ActiproSoftware.Editors.Interop.Grids.Wpf.dll. Therefore, a reference to this assembly must be added in order to leverage the property editors it provides. This assembly should have been installed in the GAC during the control installation process. However, they also will be located in the appropriate Program Files folders. See the product's Readme for details on those locations.

Property Editors

The PropertyGrid uses "property editors" to tie a properties to controls, by property name and/or property type. For example, you can tell the PropertyGrid that all properties of the type DateTime should use MyControlA and all properties of the type String should use MyControlB. This gives you a lot of control over what control is used for the various properties. In reality, the "control" is actually a DataTemplate since it will most likely be used multiple times.

Property editors are defined via an instance of the PropertyEditor class. Derivations of this class can provide default values, such as a known DataTemplate or property Type. In addition, derivations are required in order to decorate properties with EditorAttribute. EditorAttribute only allows the editor Type to be specified, therefore that Type needs to provide a default DataTemplate (via a derivation of PropertyEditor).

Note

Property editors can actually provide a DataTemplate for the value cell and the name cell, but typically the name cell does not need to be altered.

See the Property Editors topic under Actipro PropertyGrid for more information.

The Interop assembly provides a set of classes that derive from PropertyEditor and provide default values for the DataTemplate used for the value cell and the property Type. These classes include:

Class Description

BrushPropertyEditor

Represents a property editor that uses a BrushEditBox for editing Brush property values.

BytePropertyEditor

Represents a property editor that uses a ByteEditBox for editing Byte property values.

ColorPropertyEditor

Represents a property editor that uses a ColorEditBox for editing Color property values.

CornerRadiusPropertyEditor

Represents a property editor that uses a CornerRadiusEditBox for editing CornerRadius property values.

DatePropertyEditor

Represents a property editor that uses a DateEditBox for editing DateTime (date-only) property values.

DateTimePropertyEditor

Represents a property editor that uses a DateTimeEditBox for editing DateTime property values.

DoublePropertyEditor

Represents a property editor that uses a DoubleEditBox for editing Double property values.

EnumPropertyEditor

Represents a property editor that uses a EnumEditBox for editing Enum property values.

GuidPropertyEditor

Represents a property editor that uses a GuidEditBox for editing Guid property values.

Int16PropertyEditor

Represents a property editor that uses a Int16EditBox for editing Int16 property values.

Int32PropertyEditor

Represents a property editor that uses a Int32EditBox for editing Int32 property values.

Int32RectPropertyEditor

Represents a property editor that uses a Int32RectEditBox for editing Int32Rect property values.

Int64PropertyEditor

Represents a property editor that uses a Int64EditBox for editing Int64 property values.

MaskedStringPropertyEditor

Represents a property editor that uses a MaskedTextBox for editing property values.

NullableBytePropertyEditor

Represents a property editor that uses a ByteEditBox for editing Byte? property values.

NullableColorPropertyEditor

Represents a property editor that uses a ColorEditBox for editing Color? property values.

NullableCornerRadiusPropertyEditor

Represents a property editor that uses a CornerRadiusEditBox for editing CornerRadius? property values.

NullableDatePropertyEditor

Represents a property editor that uses a DateEditBox for editing DateTime? (date-only) property values.

NullableDateTimePropertyEditor

Represents a property editor that uses a DateTimeEditBox for editing DateTime? property values.

NullableDoublePropertyEditor

Represents a property editor that uses a DoubleEditBox for editing Double? property values.

NullableGuidPropertyEditor

Represents a property editor that uses a GuidEditBox for editing Guid? property values.

NullableInt16PropertyEditor

Represents a property editor that uses a Int16EditBox for editing Int16? property values.

NullableInt32PropertyEditor

Represents a property editor that uses a Int32EditBox for editing Int32? property values.

NullableInt32RectPropertyEditor

Represents a property editor that uses a Int32RectEditBox for editing Int32Rect? property values.

NullableInt64PropertyEditor

Represents a property editor that uses a Int64EditBox for editing Int64? property values.

NullablePointPropertyEditor

Represents a property editor that uses a PointEditBox for editing Point? property values.

NullableRectPropertyEditor

Represents a property editor that uses a RectEditBox for editing Rect? property values.

NullableSinglePropertyEditor

Represents a property editor that uses a SingleEditBox for editing Single? property values.

NullableSizePropertyEditor

Represents a property editor that uses a SizeEditBox for editing Size? property values.

NullableThicknessPropertyEditor

Represents a property editor that uses a ThicknessEditBox for editing Thickness? property values.

NullableTimePropertyEditor

Represents a property editor that uses a TimeEditBox for editing DateTime? (time-only) property values.

NullableTimeSpanPropertyEditor

Represents a property editor that uses a TimeSpanEditBox for editing TimeSpan? property values.

NullableVectorPropertyEditor

Represents a property editor that uses a VectorEditBox for editing Vector? property values.

PointPropertyEditor

Represents a property editor that uses a PointEditBox for editing Point property values.

RectPropertyEditor

Represents a property editor that uses a RectEditBox for editing Rect property values.

SinglePropertyEditor

Represents a property editor that uses a SingleEditBox for editing Single property values.

SizePropertyEditor

Represents a property editor that uses a SizeEditBox for editing Size property values.

ThicknessPropertyEditor

Represents a property editor that uses a ThicknessEditBox for editing Thickness property values.

TimePropertyEditor

Represents a property editor that uses a TimeEditBox for editing DateTime (time-only) property values.

TimeSpanPropertyEditor

Represents a property editor that uses a TimeSpanEditBox for editing TimeSpan property values.

VectorPropertyEditor

Represents a property editor that uses a VectorEditBox for editing Vector property values.

Each property editor exposes some of the more common settings available on their associated control. For example, the MaskedStringPropertyEditor has a Mask property that allows you to set the associated Mask on the underlying MaskedTextBox. Remember that the controls are defined using a DataTemplate, so normally it is not easy to access the settings on the controls. Using the settings available on the property editor, the underlying controls can be quickly configured.

Adding to PropertyGrid

The property editors provided can be added to a PropertyGrid using several methods, which are described below.

All Default Property Editors

All default Editors integration property editors can be easily injected into a single PropertyGrid instance by setting the attached BuiltinPropertyEditors.IsEnabled property to true.

Note

Setting this attached property simply appends our Editors integration property editors to the PropertyGrid.PropertyEditors collection. You can add your own customized property editors to that collection through XAML too, and your custom property editors will be appended after our default Editors integration property editors. This gives your custom property editors higher priority for selection over ours.

This can be done on the specific instance or via an implicit Style that targets all PropertyGrid instances in the app.

This code adds the required xmlns definitions:

xmlns:grids="http://schemas.actiprosoftware.com/winfx/xaml/grids"
xmlns:gridseditors="http://schemas.actiprosoftware.com/winfx/xaml/gridseditors"

This code shows how add the default Editors integration property editor definitions to a single PropertyGrid:

<grids:PropertyGrid ... gridseditors:BuiltinPropertyEditors.IsEnabled="True">
	...
</grids:PropertyGrid>

If you wish to apply the property editors provided to all property grid instances in the application, the attached BuiltinPropertyEditors.IsEnabled property can be set to true on a PropertyGridPropertyEditorsModifier object that you define in Application.Resources. Please see the Property Editors topic under Actipro PropertyGrid for more information on defining property editors in XAML using PropertyGridPropertyEditorsModifier.

Note

There are several property editors that cannot be installed via the built-in editors property described above and must be manually added to a PropertyGrid.PropertyEditors collection:

Specific Property Editors via PropertyGrid.PropertyEditors

Property editors can also be manually defined on a single instance of the PropertyGrid control by updating the PropertyEditors collection.

Several property editors (described above) require this since they can't be automatically set up by the built-in editors property. Note that you can apply the built-in editor and manually-defined editors on the same property grid.

This code shows how manually add several property editor definitions to a single PropertyGrid:

<grids:PropertyGrid ... >
	<grids:PropertyGrid.PropertyEditors>
		<gridseditors:DatePropertyEditor PropertyName="DateLongValue" Format="D" />
		<gridseditors:MaskedStringPropertyEditor PropertyName="MaskedString" Mask="\w+([.]\w+)*@\w+([.]\w+)+" />
		<gridseditors:EnumPropertyEditor UseDisplayAttributes="True" />
	</grids:PropertyGrid.PropertyEditors>
</grids:PropertyGrid>

Using EditorAttribute

A property editor can also be associated right on the data objects displayed by PropertyGrid using the EditorAttribute.

This code shows how associated a ColorEditBox property editor with a property:

[Editor(typeof(ColorPropertyEditor), typeof(PropertyEditor))]
public Color MyColor {
	...
}

Since EditorAttribute only allows a Type to be specified, if you need to alter any default property values, create a class that inherits the desired property editor Type and set the property values in the class' constructor.