Data Editing¶
Default In-place Eremex Editors¶
The default behavior of the TreeList and TreeView controls is to use in-place Eremex editors to display and edit cell values of common data types: If you do not explicitly specify cell editors, the TreeList and TreeView controls use in-place Eremex editors to display and edit cell values of common data types:
- Boolean values — CheckEditor
- Double values — SpinEditor
- Enumeration values — ComboBoxEditor
- Properties with a TypeConverterattribute whoseTypeConverter.GetStandardValuesSupportedmethod returnstrue—ComboBoxEditor
- Other values — TextEditor
You can explicitly specify cell editors for columns to override the default editor assignment, and to customize settings of in-place editors. The following sections provide more details about assigning editors.
When an edit operation starts in a cell, you can access and modify the active in-place editor. See the Access the Active In-place Eremex Editor section for more information.
Assign In-place Eremex Editors¶
The TreeList and TreeView controls allow you to explicitly assign in-place Eremex editors to cells (columns) to override the default editor assignment, or to customize cell editors in XAML or code-behind. Use the following properties for this purpose:
- TreeView control : TreeViewControl.EditorProperties
The TreeView control displays a single column of data. Thus, the TreeViewControl.EditorProperties property specifies the in-place editor used to edit this column's cells. 
- TreeList control: TreeListColumn.EditorProperties
Each column in the TreeList control can have its own in-place editor. Create a TreeList column (a TreeListColumn object) in the TreeListControl.Columns collection and set the column's editor using the TreeListColumn.EditorProperties property.
You can set the EditorProperties property to the following objects that specify the in-place editor type (all of these objects are BaseEditorProperties descendants):
- ButtonEditorProperties— Contains settings specific to the- ButtonEditorcontrol.
- CheckEditorProperties— Contains settings specific to the- CheckEditorcontrol.
- ComboBoxEditorProperties— Contains settings specific to the- ComboBoxEditorcontrol.
- DateEditorProperties— Contains settings specific to the- DateEditorcontrol.
- HyperlinkEditorProperties— Contains settings specific to the- HyperlinkEditorcontrol.
- MemoEditorProperties— Contains settings specific to the- MemoEditorcontrol.
- PopupColorEditorProperties— Contains settings specific to the- PopupColorEditorcontrol.
- SegmentedEditorProperties— Contains settings specific to the- SegmentedEditorcontrol.
- SpinEditorProperties— Contains settings specific to the- SpinEditorcontrol.
- TextEditorProperties— Contains settings specific to the- TextEditorcontrol.
Assume that you set the EditorProperties property to a SpinEditorProperties object. In display mode (cell editing is not active), the TreeList/TreeView control emulates a SpinEditor in the target column's cells, using the settings of the SpinEditorProperties object. No real SpinEditor is created until an edit operation starts in a cell. When a user starts cell editing, the TreeList/TreeView control creates a real SpinEditor in-place editor in the focused cell. After the edit operation is complete, the control destroys the real SpinEditor and starts emulating a SpinEditor in this cell. See Access the Active In-place Eremex Editor to learn how to access the real cell editor.
Example - How to use ButtonEditor as an in-place editor in a treelist column¶
The following code assigns a ButtonEditor in-place editor to a TreeList column. 
xmlns:mxtl="https://schemas.eremexcontrols.net/avalonia/treelist" 
xmlns:mxe="https://schemas.eremexcontrols.net/avalonia/editors"
<mxtl:TreeListControl.Columns>
    <mxtl:TreeListColumn Header="Name" FieldName="Name">
        <mxtl:TreeListColumn.EditorProperties>
            <mxe:ButtonEditorProperties>
                <mxe:ButtonEditorProperties.Buttons>
                    <mxe:ButtonSettings Content="Clear" 
                     Command="{Binding $parent[mxtl:CellControl].DataControl.
                               DataContext.ClearValueCommand}"/>
                </mxe:ButtonEditorProperties.Buttons>
            </mxe:ButtonEditorProperties>
        </mxtl:TreeListColumn.EditorProperties>
    </mxtl:TreeListColumn>
</mxtl:TreeListControl.Columns>
Example - How to use ComboBoxEditor as an in-place editor in treeview¶
The following code assigns a ComboBoxEditor in-place editor to a TreeView.
xmlns:mxtl="https://schemas.eremexcontrols.net/avalonia/treelist" 
xmlns:mxe="https://schemas.eremexcontrols.net/avalonia/editors"
<mxtl:TreeViewControl.EditorProperties>
    <mxe:ComboBoxEditorProperties ItemsSource="{Binding Families}"/>
</mxtl:TreeViewControl.EditorProperties>
Assign In-place Eremex Editors Using Templates¶
The TreeList and TreeView controls allow you to use templates to assign Eremex editors to columns. Use the following properties for this purpose:
- TreeListColumn.CellTemplate
- TreeViewControl.CellTemplate
Set the x:Name property to "PART_Editor" for the Eremex editor defined in a template. This ensures automatic binding of the editor's value (BaseEditor.EditorValue) to the column's field. Additionally, 
the editor's appearance settings (border visibility and foreground colors in the active and inactive states) will be managed by the TreeList/TreeView control.
xmlns:mxtl="https://schemas.eremexcontrols.net/avalonia/treelist"
xmlns:mxe="https://schemas.eremexcontrols.net/avalonia/editors"
...
<mxtl:TreeListColumn Header="Phone" FieldName="Phone">
    <mxtl:TreeListColumn.CellTemplate>
        <DataTemplate>
            <mxe:ButtonEditor x:Name="PART_Editor">
                <mxe:ButtonEditor.Buttons>
                    <mxe:ButtonSettings Content="..."/>
                </mxe:ButtonEditor.Buttons>
            </mxe:ButtonEditor>
        </DataTemplate>
    </mxtl:TreeListColumn.CellTemplate>
</mxtl:TreeListColumn>
Custom Editors¶
You can specify custom editors for cells in the TreeList and TreeView controls using the following approaches:
- Assign an editor directly to a specific column.
- Dynamically assign editors to columns based on the data type of the column's underlying object. This technique is applicable to the TreeList control.
See the Custom Editors topic for more information.
Get and Set Cell Values¶
The TreeList and TreeView controls expose the following API to obtain and set cell values:
- TreeListControl.GetCellDisplayText
- TreeListControl.GetCellValue
- TreeListControl.SetCellValue
- TreeViewControl.GetCellDisplayText
- TreeViewControl.GetCellValue
- TreeViewControl.SetCellValue
Access the Active In-place Eremex Editor¶
- ActiveEditorproperty — Returns the active in-place editor.
When an in-place Eremex editor is assigned to a TreeList/TreeView column (implicitly, or explicitly using the EditorSettings property and templates), the control emulates the specified in-place editor in this column's cells in display mode (when cell editing is not active). No real in-place editor exists at this moment. The emulation of cell editors in display mode improves application performance.
When a user starts editing a cell, the control creates a real in-place editor. At this moment, you can use the control's ActiveEditor property to access the real Eremex editor instance. When a cell loses focus, the real editor is destroyed, and the ActiveEditor property returns null.
- ShowingEditorevent — Allows you to receive notifications when edit operations start in row cells. You can safely access the- ActiveEditorproperty in a- ShowingEditorevent handler.
Show a Cell Editor¶
- ShowEditormethod — Activates a cell editor in the focused cell.
- ShowingEditorevent — Allows you to prevent a cell editor from being activated by users in specific cases. While handling the- ShowingEditorevent, set the- Cancelevent parameter to- trueto disable an editor activation.
Close the Active In-place Editor¶
- CloseEditormethod — Saves changes made in the cell editor and closes the editor.
- 
HideEditormethod — Closes the cell editor without saving any changes.
- 
HiddenEditorevent — Fires after the active cell editor is closed.
Save the Changes Made in an In-place Editor¶
- CloseEditormethod — Saves changes made in the cell editor and closes the editor.
- PostEditormethod — Saves changes made in the active cell editor without closing the editor.