External selection of links

First, I was reading the About LabelNode in the Link topic and it was very helpful. I’d encourage you to add this to the documentation.

Here’s my problem: I’m using WPF with a GraphLinksModel. Sometimes my diagram selection is driven by controls outside of the diagram. Selecting a business object outside of the diagram should select it inside as well. Propagating the selection to nodes is straight forward: I call GraphLinksModel.FindNodeByKey(), pass the result as a parameter to PartManager.FindNodeForData(), and then call Diagram.Select on that part. However, propagating selection to the links is more challenging because there’s no GraphLinksModel.FindLinkByKey method.

I was thinking of using nodes where I’ve set IsLinkLabel=true. I could then put the key for the link model on that node’s model and find it using the same technique as above. I’m a little fuzzy on how I’d actually go from that link label node over to the link itself. Furthermore I would not want users to actually create links to and from the label nodes, so I’d probably want to set LinkableFrom and LinkableTo as false in my XAML. Is there a better solution for my problem?

Since you are using a GraphLinksModel, you must already have a particular link data object in mind to select. Thus you just need to call PartManager.FindLinkForData to get the Link element.

If you want the link that a given node is the label for, use the Node.LabeledLink property.