Edit and Format Text Commands in WPF Diagram (SfDiagram)

29 Jan 20253 minutes to read

EditAnnotation

The EditAnnotation command is used to enable editing mode for the annotation of the selected element. And in the case of multiple selection, editing will be enabled for the first selected element.

<Button Height="50" Content="EditAnnotation" Name="EditAnnotation" Command="Syncfusion:DiagramCommands.EditAnnotation"></Button>
IGraphInfo graphinfo = diagramcontrol.Info as IGraphInfo;
graphinfo.Commands.EditAnnotation.Execute(null);

ToggleBold Command

The ToggleBold command is used to toggle the bold style for the annotation of the selected element in the diagram.

<Button Height="50" Content="ToggleBold" Name="ToggleBold" Command="Syncfusion:DiagramCommands.ToggleBold"></Button>
IGraphInfo graphinfo = diagramcontrol.Info as IGraphInfo;
graphinfo.Commands.ToggleBold.Execute(null);

ToggleItalic Command

The ToggleItalic command is used to toggle the italic style for the annotation of the selected element in the diagram.

<Button Height="50" Content="ToggleItalic" Name="ToggleItalic" Command="Syncfusion:DiagramCommands.ToggleItalic"></Button>
IGraphInfo graphinfo = diagramcontrol.Info as IGraphInfo;
graphinfo.Commands.ToggleItalic.Execute(null);

ToggleUnderline Command

The ToggleUnderline command is used to toggle the underline for the annotation of the selected elements in the diagram.

<Button Height="50" Content="ToggleUnderline" Name="ToggleUnderline" Command="Syncfusion:DiagramCommands.ToggleUnderline"></Button>
IGraphInfo graphinfo = diagramcontrol.Info as IGraphInfo;
graphinfo.Commands.ToggleUnderline.Execute(null);

ToggleStrikeThrough Command

The ToggleStrikeThrough command is used to toggle the strikethrough style for the annotation of the selected elements in the diagram.

<Button Height="50" Content="ToggleStrikeThrough" Name="ToggleStrikeThrough" Command="Syncfusion:DiagramCommands.ToggleStrikeThrough"></Button>
IGraphInfo graphinfo = diagramcontrol.Info as IGraphInfo;
graphinfo.Commands.ToggleStrikeThrough.Execute(null);

Cancel command

The Cancel command is used to perform either one of the below action with higher priority.

  • Stops the annotation editing and accepts the current value.
  • Clears the selection of or keyboard focus on the diagram elements.
<Button Height="50" Content="Cancel" Name="Cancel" Command="Syncfusion:DiagramCommands.Cancel"></Button>
IGraphInfo graphinfo = diagramcontrol.Info as IGraphInfo;
graphinfo.Commands.Cancel.Execute(null);

Gif for EditAnnotation command

View sample in GitHub