- AlignLeft command
- AlignRight command
- AlignCenter command
- AlignTop command
- AlignBottom command
- AlignMiddle command
Contact Support
Alignment Commands in WPF Diagram (SfDiagram)
29 Jan 20253 minutes to read
Alignment commands are used to align the selected objects such as Nodes and Connectors on a page with respect to a reference object(first item in the selection list).
AlignLeft command
The AlignLeft
command is used to align all the selected objects along the left corner of the reference object.
<Button Height="50" Content="AlignLeft" Name="AlignLeft" Command="Syncfusion:DiagramCommands.AlignLeft"></Button>
IGraphInfo graphinfo = diagramcontrol.Info as IGraphInfo;
// sets direction to Left
graphinfo.Commands.AlignLeft.Execute(null);
AlignRight command
The AlignRight
command is used to align all the selected objects along the right corner of the reference object.
<Button Height="50" Content="AlignRight" Name="AlignRight" Command="Syncfusion:DiagramCommands.AlignRight"></Button>
IGraphInfo graphinfo = diagramcontrol.Info as IGraphInfo;
// sets direction to Right
graphinfo.Commands.AlignRight.Execute(null);
AlignCenter command
The AlignCenter
command is used to center all selected objects vertically. It aligns selected objects to the center with respect to the horizontal axis by changing the x-coordinate of the object.
<Button Height="50" Content="AlignCenter" Name="AlignCenter" Command="Syncfusion:DiagramCommands.AlignCenter"></Button>
IGraphInfo graphinfo = diagramcontrol.Info as IGraphInfo;
// sets direction to Center vertically
graphinfo.Commands.AlignCenter.Execute(null);
AlignTop command
The AlignTop
command is used to align all the selected objects along the top corner of the reference object.
<Button Height="50" Content="AlignTop" Name="AlignTop" Command="Syncfusion:DiagramCommands.AlignTop"></Button>
IGraphInfo graphinfo = diagramcontrol.Info as IGraphInfo;
// sets direction to Top
graphinfo.Commands.AlignTop.Execute(null);
AlignBottom command
The AlignBottom
command is used to align all the selected objects along the bottom corner of the reference object.
<Button Height="50" Content="AlignBottom" Name="AlignBottom" Command="Syncfusion:DiagramCommands.AlignBottom"></Button>
IGraphInfo graphinfo = diagramcontrol.Info as IGraphInfo;
// sets direction as Bottom
graphinfo.Commands.AlignBottom.Execute(null);
AlignMiddle command
The AlignMiddle
command is used to center all selected objects horizontally. It aligns selected objects to the center with respect to the vertical axis by changing the y-coordinate of the object.
<Button Height="50" Content="AlignMiddle" Name="AlignMiddle" Command="Syncfusion:DiagramCommands.AlignMiddle"></Button>
IGraphInfo graphinfo = diagramcontrol.Info as IGraphInfo;
// sets direction to Center horizontally
graphinfo.Commands.AlignCenter.Execute(null);