BoldSign®Effortlessly integrate e-signatures into your app with the BoldSign® API. Create a sandbox account!
Hello,
I would like to restrict connectors to be connected only to other connectors or nodes. I looked through the constraints of the diagram and the connectors but couldn't figure out how.
Thank you.
Hi Eshar,
Requirement: How to delete the connector being disconnected from the object.
We can achieve your requirement in our SfDiagram control, using ConnectorSourceChangedEvent and ConnectorTargetChangedEvent. We removed the connectors from the collection in those events based on the necessary conditions. The conditions are if the DragState of the connector is completed and the Source node or Target node is null. You can change the condition based on your need. We have provided the code snippet and sample for your reference.
//diagram is the instance of the SfDiagram
(diagram.Info as IGraphInfo).ConnectorSourceChangedEvent += MainWindow_ConnectorSourceChangedEvent; (diagram.Info as IGraphInfo).ConnectorTargetChangedEvent += MainWindow_ConnectorTargetChangedEvent;
private void MainWindow_ConnectorSourceChangedEvent(object sender, ChangeEventArgs<object, ConnectorChangedEventArgs> args) { //Check whether the connector dragging is completed or not. if (args.NewValue.DragState == DragState.Completed) { //Check whether the connector's source node or target node is null or not if ((args.Item as ConnectorViewModel).SourceNode == null || (args.Item as ConnectorViewModel).TargetNode == null) { //Removed the connector from the connector collection. (diagram.Connectors as ConnectorCollection).Remove((ConnectorViewModel)args.Item); } } }
private void MainWindow_ConnectorTargetChangedEvent(object sender, ChangeEventArgs<object, ConnectorChangedEventArgs> args) { //Check whether the connector dragging is completed or not. if (args.NewValue.DragState == DragState.Completed) { //Check whether the connector's source node or target node is null or not if ((args.Item as ConnectorViewModel).SourceNode == null || (args.Item as ConnectorViewModel).TargetNode == null) { (diagram.Connectors as ConnectorCollection).Remove((ConnectorViewModel)args.Item); } } }
|
Regards,
Arun Kumar S
Thank you very much
Hi Eshar Gal,
You're welcome. Please let us know if you need further assistance. As always, we are happy to help you out.
Regards,
Preethi R