Clipboard Commands in WPF Diagram (SfDiagram)

29 Jan 20252 minutes to read

Clipboard commands are used to cut or copy the selected diagram objects to the clipboard and paste the valid clipboard content into the diagram page.

Cut command

The Cut command is used to cut the selected diagram objects to the clipboard. Cut command can be executed by the keyboard shortcut CTRL + X.

<Button Height="50" Content="Cut" Name="Cut" Command="Syncfusion:DiagramCommands.Cut"></Button>
IGraphInfo graphinfo = diagramcontrol.Info as IGraphInfo;

//Cuts the selected elements from the diagram to the diagram’s clipboard
graphinfo.Commands.Cut.Execute(null);

Copy command

The Copy command is used to copy the selected diagram objects to the clipboard. Copy command can be executed by the keyboard shortcut CTRL + C.

<Button Height="50" Content="Copy" Name="Copy" Command="Syncfusion:DiagramCommands.Copy"></Button>
IGraphInfo graphinfo = diagramcontrol.Info as IGraphInfo;

//Copies the selected elements from the diagram to the diagram’s clipboard.
graphinfo.Commands.Copy.Execute(null);

Paste command

The Paste command is used to paste the clipboard content to the diagram page. Paste command can be executed by the keyboard shortcut CTRL + V.

<Button Height="50" Content="Paste" Name="Paste" Command="Syncfusion:DiagramCommands.Paste"></Button>
IGraphInfo graphinfo = diagramcontrol.Info as IGraphInfo;

//Pastes the diagram’s clipboard data (nodes or connectors) into the Diagram.
graphinfo.Commands.Paste.Execute(null);

Duplicate command

The Duplicate command is used to copy the selected diagram objects to the clipboard and paste the clipboard content to the diagram page. Duplicate command can be executed by the keyboard shortcut CTRL + D.

<Button Height="50" Content="Duplicate" Name="Duplicate" Command="Syncfusion:DiagramCommands.Duplicate"></Button>
IGraphInfo graphinfo = diagramcontrol.Info as IGraphInfo;

//Copy the diagram objects and Paste the clipboard's data (nodes or connectors) into the Diagram.
graphinfo.Commands.Duplicate.Execute(null);

Clipboard gif

View sample in GitHub

See Also

How to Display Different QuickCommands Based on Nodes in WPF Diagram?

How to disable or override clipboard support