Category / Section
How to restrict the node dragging within boundaries in the WPF Diagram (SfDiagram)?
1 min read
Nodes can be restricted to drag within the specified region alone by using the DragLimit and EditableArea properties of the ScrollSettings class and the SelectorChangedEvent in WPF Diagram (SfDiagram) control. Drag limitation will be enabled by the Block argument of SelectorChangedEvent.
C#
SfDiagram diagram = new SfDiagram(); (diagram.Info as IGraphInfo).SelectorChangedEvent += Diagram_SelectorChangedEvent diagram.ScrollSettings.DragLimit = ScrollLimit.Limited; diagram.ScrollSettings.EditableArea = new Rect(0, 0, 1000, 800); private void Diagram_SelectorChangedEvent(object sender, SelectorChangedEventArgs args) { args.BlockCursor = Cursors.No; args.Block = true; }