Spacing Commands in WPF Diagram (SfDiagram)

21 Sep 20231 minute to read

Spacing commands are used to place selected objects on the page at equal intervals from each other. The objects are spaced within the bounds of the first and last objects in the selection.

SpaceAcross command

The SpaceAcross command is used to place selected objects on the page at equal intervals from each other horizontally.

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

// Equally spaces the selected nodes horizontally
graphinfo.Commands.SpaceAcross.Execute(null);

SPace Across

SpaceDown command

The SpaceDown command is used to place selected objects on the page at equal intervals from each other vertically.

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

// Equally spaces the selected nodes vertically
graphinfo.Commands.SpaceDown.Execute(null);

SPace Down

View sample in GitHub