How to get GoXam.Link object from LinkData (LinkType)


I have a event handler attached to GoXamModel.Changed and in ModelChange.AddedLink I want to get the corresponding Link object. The parameter i.e ModelChangedEventArgs of the event would give me the LinkData(LinkType) and from this LinkData I want to extract the corresponding Link.

Could you suggest something about this ?


myDiagram.PartManager.FindLinkForData(linkdata, myDiagram.Model)


I tried using the above mentioned method, it returns null.

Just debugged this scenario and got some additional infos.

When the ModelChanged event is handled, PartManager.Links contains a link object.
But the is pointing to a temporaryNode not to the linkData which we get from ModelChangedEventArgs.

Please refer the screenshot.

When is this happening? If it is during a LinkingTool operation, wait until the Diagram.LinkDrawn event happens. Or just skip events happening to temporary Parts.

This is happening when DiagramModel.Changed event is handled for the Addedlink operation

Depending on the order in which Changed events occur, I can see how the Link might not yet have been made in a particular Diagram that is watching for those events.

What are you trying to accomplish? What is happening at the time that the link is being added for which you are receiving that ModelChangedEventArgs?

I just want to get the GoXam.Link object from ModelChangedEventArgs in DiagramModelChanged event.

Depending on the situation, that Link might not yet exist. Or might never exist. Or might exist only temporarily. That’s why I’m asking about what is going on.

Actually, the way we have desined/made use of GoXam is that, every change in the diagram should be taken as part of diagramModified event and the same event should propogate to further levels in our application.

in the same diagramModified event I am able to get the nodeAdded deleted etc correctly but in case of links facing the above problem( mentioned in the image) and unable to get the link information correctly.

Any other way to get the Link object in this regard ?

Well, the first point is that if Diagram.SkipsUndoManager is true, it must be a temporary Part that is being modified, so you probably want to skip that Changed event.

But I don’t know enough about what you are doing to be able to answer you specifically.