We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to restrict the child node dragging whereas allow group dragging in WPF Diagram (SfDiagram)?

Platform: WPF |
Control: SfDiagram |
Published Date: April 27, 2020 |
Last Revised Date: July 15, 2021

The Groups and Nodes can be dragged on the WPF Diagram (SfDiagram) page by default. By using the Constraints property of Group and Node, groups can be dragged whereas nodes that are child elements of a group could not be dragged.


SfDiagram diagram = new SfDiagram();
(diagram.Info as IGraphInfo).ItemSelectedEvent += MainWindow_ItemSelectedEvent;
private void MainWindow_ItemSelectedEvent(object sender, DiagramEventArgs args)
  if ((args as ItemSelectedEventArgs).Item is IGroup)
    foreach (var item in (((args as ItemSelectedEventArgs).Item as IGroup).Nodes) as ObservableCollection<NodeViewModel>)
      (item as INode).Constraints = NodeConstraints.Default;
  else if ((args as ItemSelectedEventArgs).Item is INode)
    ((args as ItemSelectedEventArgs).Item as INode).Constraints = NodeConstraints.Default & ~(NodeConstraints.Draggable | NodeConstraints.InheritDraggable);

A close up of a map

Description automatically generated

View sample in GitHub.

2X faster development

The ultimate WPF UI toolkit to boost your development speed.
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile