Sizing Commands in WPF Diagram (SfDiagram)

21 Sep 20231 minute to read

Sizing commands are used to resize all selected object based on width, height, and size of the reference object (FirstSelectedItem).

SameSize command

The SameSize command is used to resize all the selected object based on the size of the first item in the selection list.

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

//Scales the selected items to the size of first selected object
graphinfo.Commands.SameSize.Execute(null);

SameHeight command

The SameHeight command is used to resize all the selected object based on the height of the first item in the selection list.

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

//Vertically scales the selected items to the height of first selected object
graphinfo.Commands.SameHeight.Execute(null);

SameWidth command

The SameWidth command is used to resize all the selected object based on the width of the first item in the selection list.

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

//Horizontally scales the selected items to the width of first selected object
graphinfo.Commands.SameWidth.Execute(null);

Sizing commands

View sample in GitHub