Nudge Commands in WPF Diagram (SfDiagram)

5 May 20211 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. The Nudge Commands as follows.

Commands Description
NudgeUp The NudgeUp command moves the selected object towards the top by 1 pixel.
NudgeDown The NudgeDown command moves the selected object towards the bottom by 1 pixel.
NudgeLeft The NudgeLeft command moves the selected object towards the left by 1 pixel.
NudgeRight The NudgeRight 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