To activate the standard in-place editing of the text of Diagramming for WinUI objects, set the AllowInplaceEdit property to true. AllowInplaceEdit allows in-place editing the content of a diagram element by double-clicking it. In-place editing mode can be accepted and exited by clicking anywhere outside the text-field.
If you want to change the way of accepting and rejecting changes, the following Diagram properties allow by pressing the ENTER and ESC keys to perform that: InplaceEditAcceptOnEnter and InplaceEditCancelOnEsc. When InplaceEditAcceptOnEnter is set to true, pressing the ENTER key causes accepting changes and exiting in-place editing mode. If InplaceEditAcceptOnEnter is set to false, pressing ENTER inserts a new line in the text while in-place editing mode is active. If InplaceEditCancelOnEsc is set to true, pressing the ESC key performs rejecting changes and exiting in-place editing mode.
In-place editing can be applied to the following properties: ShapeNode.Text, DiagramLink.Text, Cell.Text, and TableNode.Caption. For tables, both captions and cells can be edited in this way.
When in-place editing of a node is completed, the NodeTextEdited event is raised. LinkTextEdited event is raised when in-place editing of a DiagramLink object completes.
By default, Diagramming for WinUI creates a TextBox 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.
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.