Get the node on which Drop occured

When a symbol is dropped on the diagram, I need to know if it was dropped on another node.

Is there a way to do that?


3 Replies

DT Deepa Thiruppathy Syncfusion Team March 1, 2022 01:38 PM UTC

Hi Smadar, 
 
Requirement: How to get the elements that are intersected with dropped node 
 
It can be achieved by using ItemDropEvent where we can identify whether the node is dropped over another node. Also, AllowDrop constraint added for all the nodes through ItemAddedEvent to trigger ItemDropEvent for drag and dropping the existing node in the diagram over another node. 
 
Code snippet: 
//Enable allow drop constraint to nodes that are added into diagram page. 
private void MainWindow_ItemAdded(object sender, ItemAddedEventArgs args) 
{ 
    if (args.Item is INode) 
        (args.Item as INode).Constraints |= NodeConstraints.AllowDrop; 
} 
 
//Event to get intersecting elements of currently dropped item. 
private void MainWindow_ItemDropEvent(object sender, ItemDropEventArgs args) 
{ 
    List<object> intersectingElements = args.Target as List<object>; 
    foreach (var node in intersectingElements) 
    { 
        //You can add your own logic. 
    } 
} 
 
Regards, 
Deepa Thiruppathy 



ST Smadar Tsdaka March 1, 2022 07:43 PM UTC

Thanks. That was very helpful



DT Deepa Thiruppathy Syncfusion Team March 2, 2022 05:44 AM UTC

Our pleasure. Please let us know if you require any further assistance. 


Loader.
Up arrow icon