This is a migrated thread and some comments may be shown as answers.

Customize Diagram Nudge command

1 Answer 44 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Ken
Top achievements
Rank 1
Ken asked on 06 Mar 2014, 11:07 PM
I'm looking though the documentation trying to figure out how far the Nudge command moves an item in a diagram.  I'm also interested in how you can perform a Nudge command programmatically.  Any help would be appreciated, thanks.

1 Answer, 1 is accepted

Sort by
0
Tina Stancheva
Telerik team
answered on 11 Mar 2014, 07:08 PM
Hello Ken,

The only way to nudge a RadDiagramItem is through the DiagramCommands.Nudge command. You can invoke it both in code behind or in xaml. In both cases you can control its behavior through the CommandParameter that you pass. This parameter can be a single string representing one the following values:
  • "Left"
  • "Right"
  • "Up"
  • "Down"
or a string of the form "direction; amount", the 'direction' being a value from the above list of direction values. The 'amount' options are:
  • "Small" - if the RadDiagram IsSnapToGridEnabled property is set to true then this amount would mean that the nudge should happen once to the appointed direction using the SnapX/Y value as a step (these values are also coming from the RadDiagram definition and you can easily change them). If the RadDiagram IsSnapToGridEnabled property is false, a "Small" amount indicates a step of 5 pixels;
  • "Large" - if the RadDiagram IsSnapToGridEnabled property is set to true then this amount would mean that the nudge should happen once to the appointed direction using 5*SnapX/Y value as a step (these values are also coming from the RadDiagram definition and you can easily change them). If the RadDiagram IsSnapToGridEnabled property is false, a "Large" amount indicates a step of 10 pixels;
  • any number - if you provide a number in the CommandParameter, this number would indicate the number of pixels to be used as a step for the Nudge command.

If you decide to invoke the command in code-behind, then you can use the following syntax:

private void RadButton_Click(object sender, RoutedEventArgs e)
{
    DiagramCommands.Nudge.Execute("Left;45", xDiagram.Shapes[0] as IInputElement);        
}

I hope that information helps.

Regards,
Tina Stancheva
Telerik

DevCraft Q1'14 is here! Watch the online conference to see how this release solves your top-5 .NET challenges. Watch on demand now.

Tags
Diagram
Asked by
Ken
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
Share this question
or