Customize Diagram Nudge command

2 posts, 0 answers
  1. Ken
    Ken avatar
    3 posts
    Member since:
    Nov 2013

    Posted 06 Mar 2014 Link to this post

    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.
  2. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 11 Mar 2014 Link to this post

    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.

  3. UI for WPF is Visual Studio 2017 Ready
Back to Top