Search
In-place Editing the Contents of Items

Standard in-place editing

To activate the standard in-place editing of the text of MindFusion.Diagramming for .NET MAUI objects, set the AllowInplaceEdit property to true. AllowInplaceEdit allows in-place editing the content of a diagram element through the context menu. To display the context menu, tap and hold over an item without moving. In-place editing mode can be accepted and exited by clicking anywhere outside the text-field.

In-place editing can be applied to the following properties: ShapeNode.TextDiagramLink.Text, TableNode.Cell.Text, TableNode.Caption and ContainerNode.Caption. For tables, both captions and cells can be edited in this way.

If you want to enable/disable in-place editing of a specific table's cell, handle the CellTextEditing event. To enable/disable in-place editing of nodes, handle the NodeTextEditing event. For a DiagramLink object, the LinkTextEditing event is raised while in-place editing. These validation events let you prevent users from editing the text in the particular object if it is necessary.

When in-place editing of a node is completed, the NodeTextEdited event is raised. For a table's cell, handle the CellTextEdited event. LinkTextEdited event is raised when in-place editing of a DiagramLink object completes.

By default, MindFusion.Diagramming creates an Editor control to let users edit item's text. The EnterInplaceEditMode event allows customizing the properties of that control, or attaching event handlers to it. When leaving in-place editing mode, the LeaveInplaceEditMode event is raised. This event is raised in all cases of closing the in-place editing control, for example, when the user accepts or cancels the changes made to an item's text, or when the EndEdit method is called.

To enter in-place editing mode programmatically and let users edit an item's text inline, call the BeginEdit method of Diagram. The EndEdit method exits in-place editing mode.

In-place editing of custom items

The InplaceEditable interface allows implementing the standard in-place editing for custom defined items. By means of the methods of this interface, you can specify the position of the in-place editing textbox control and copy the entered text to a property of the edited item.

GetEditRect returns the destination rectangle of the in-place editing box. GetTextToEdit represents the initial contents of the in-place editing box. SetEditedText sets the edited text to the object after completing the in-place editing.

Using custom editor controls

Handle the CreateEditControl event to create a custom in-place editor control. This event is raised if AllowInplaceEdit is enabled and the user selects the Edit icon from item's context menu, or when the application invokes the BeginEdit method of DiagramView. When the event is raised, set its EditControl argument to an instance of your custom editor class. You can use any MAUI control as editor instead of the default Editor. The event's Bounds property lets you specify the control's size and position.

When the user exits in-place editing mode by clicking outside the editor, MindFusion.Diagramming raises the DestroyEditControl event. Handle it to transfer the values entered into the editor to the respective properties of the edited item, and finally destroy or hide the editor control.