Consider a I have 2 nodes and a link connecting the nodes. Default behavior is that when I delete anyone of the nodes the link is also deleted along with the node.
I want to have a feature where in if I delete a node the link should not be deleted rather it should be a valid unconnected link.
Ah, yes – it’s the model that is enforcing that behavior.
OK, try this instead, which first disconnects the links from the nodes:
myDiagram.SelectionDeleting += (object sender, DiagramEventArgs e) => {
var m = myDiagram.Model as ILinksModel;
foreach (var n in myDiagram.SelectedParts.OfType<Node>()) {
foreach (var l in n.LinksConnected) {
if (l.FromNode == n) m.SetLinkFromPort(l.Data, null, null);
if (l.ToNode == n) m.SetLinkToPort(l.Data, null, null);
}
}
};
Not easily. If GraphLinksModel.RemoveNode were virtual, one could override that to just call DeleteNode. (Although if the node were a group, it should first remove all of the member parts.) Sorry.
Actually I want to find the links connected to a node using nodeData in the deleting event we are finding it using selectedPart which is straight forward. But rather I would have to it in some way using nodedata and Model.
Node.LinksConnected is implemented by asking the model to get the collection of connected links. So are all of the other properties and methods of Nodes and Links that involve relationships. So I don’t understand what you want.