Nudge Commands in WPF Diagram (SfDiagram)

28 Jun 20241 minute to read

Nudge commands are used to move the selected elements towards up, down, left, or right by 1 pixel. The IMoveParameter is provided to customize the movement of the selected objects.

Below are the specific nudge commands:

Commands Description
MoveUp The MoveUp command moves the selected object towards the top by 1 pixel.
MoveDown The MoveDown command moves the selected object towards the bottom by 1 pixel.
MoveLeft The MoveLeft command moves the selected object towards the left by 1 pixel.
MoveRight The MoveRight command moves the selected object towards the right by 1 pixel.
<Syncfusion:MoveParameter MoveDelta="5" x:Key="MoveupCommandParameter"/> 

<Button Height="50" Content="MoveUp" Name="MoveUp" Command="Syncfusion:DiagramCommands.MoveUp" CommandParameter="{StaticResource MoveupCommandParameter}"></Button>
IGraphInfo graphinfo = diagramcontrol.Info as IGraphInfo;

// Nudge up the selected objects
graphinfo.Commands.MoveUp.Execute(new MoveParameter() { MoveDelta = 5 });

Nudge gif

View sample in GitHub