Data Editing
Default In-place Eremex Editors
If you do not explicitly specify in-place editors for rows, the PropertyGrid control uses in-place Eremex editors to display and edit row values of common data types.
The following list shows Eremex editors associated with common data types:
- Boolean values —
CheckEditor
- Double values —
SpinEditor
- Enumeration values —
ComboBoxEditor
- Properties with a
TypeConverter
attribute whoseTypeConverter.GetStandardValuesSupported
method returnstrue
—ComboBoxEditor
- Other values —
TextEditor
You can dynamically access and modify instances of in-place Eremex editors when these editors are activated. See the Access the Active In-place Eremex Editor section for more details.
Assign In-place Eremex Editors
You can explicitly assign in-place Eremex editors to rows if you need to override the default editor assignment, or to customize row editors in XAML or code-behind.
Use the PropertyGridRow.EditorProperties
property for this purpose, as follows:
Create and customize an instance of a helper
...EditorProperties
class that stores settings specific to the required in-place editor. These helper classes are allBaseEditorProperties
descendants:ButtonEditorProperties
— Contains settings specific to theButtonEditor
control.CheckEditorProperties
— Contains settings specific to theCheckEditor
control.ColorEditorProperties
— Contains settings specific to theColorEditor
control.ComboBoxEditorProperties
— Contains settings specific to theComboBoxEditor
control.HyperlinkEditorProperties
— Contains settings specific to theHyperlinkEditor
control.PopupColorEditorProperties
— Contains settings specific to thePopupColorEditor
control.PopupEditorProperties
— Contains settings specific to thePopupEditor
control.SegmentedEditorProperties
— Contains settings specific to theSegmentedEditor
control.SpinEditorProperties
— Contains settings specific to theSpinEditor
control.TextEditorProperties
— Contains settings specific to theTextEditor
control.
Set the
PropertyGridRow.EditorProperties
property to the created...EditorProperties
instance.
xmlns:mxpg="https://schemas.eremexcontrols.net/avalonia/propertygrid"
xmlns:mxe="https://schemas.eremexcontrols.net/avalonia/editors"
<mxpg:PropertyGridRow FieldName="OrderNo">
<mxpg:PropertyGridRow.EditorProperties >
<mxe:ButtonEditorProperties TextWrapping="Wrap" />
</mxpg:PropertyGridRow.EditorProperties>
</mxpg:PropertyGridRow>
The PropertyGridRow.CellTemplate
property is another way to assign an Eremex editor to a row. Ensure that the Eremex editor has the x:Name
property set to "PART_Editor". In this case, PropertyGrid automatically binds the editor's EditorValue
property to the row's bound field. Additionally, PropertyGrid starts to maintain the in-place editor's appearance settings (the borders' visibility and foreground colors in the active and inactive states).
xmlns:mxpg="https://schemas.eremexcontrols.net/avalonia/propertygrid"
xmlns:mxe="https://schemas.eremexcontrols.net/avalonia/editors"
...
<mxpg:PropertyGridRow FieldName="Caption">
<mxpg:PropertyGridRow.CellTemplate>
<DataTemplate>
<mxe:ButtonEditor x:Name="PART_Editor">
<mxe:ButtonEditor.Buttons>
<mxe:ButtonSettings Content="..."/>
</mxe:ButtonEditor.Buttons>
</mxe:ButtonEditor>
</DataTemplate>
</mxpg:PropertyGridRow.CellTemplate>
</mxpg:PropertyGridRow>
Custom Editors
PropertyGrid allows you to specify custom editors for row cells. You can assign an editor directly to a specific row, or dynamically assign editors to rows based on the data type of the row's underlying object. See the following topic for more information: Custom Editors.
Access the Active In-place Eremex Editor
To improve the control's performance, PropertyGrid uses light-weight versions of in-place Eremex editors when it renders cell values in display mode (when text editing is not active). When a text edit operation starts in a cell, the in-place editor switches from its lightweight version to a fully-functioning version. In this case, you can use the ActiveEditor
property to access the Eremex editor instance. When a row cell loses focus, the editor switches back to its lightweight version, and the ActiveEditor
property returns null
.
Handle the ShowingEditor
event to receive notifications when edit operations start in row cells. You can safely access the ActiveEditor
property in a ShowingEditor
event handler.
Disable Editor Activation
To prevent a cell editor from being activated in specific cases, you can handle the ShowingEditor
event and set the event handler's Cancel
parameter to true
.