Links Siblings

Is there a way to get at a currently selected links siblings? For example, if I have multiple links coming out of a node going to many other nodes, can I access all the links associated with the currently selected link? Is there a certain place in the documentation you can direct me to? Thanks in advance.

There are no “siblings” for a Link. But in a tree-structured graph, perhaps the “parent” is the Link.FromNode, in which case the Link.FromNode.NodesOutOf are all of the “children” of the “parent”, including the Node that is at the other end of the chosen Link, the Link.ToNode.

Is there anything similar in the GraphLinksModelLinkData?

The link data and node data classes are specific to your app, so I cannot answer whether such functionality exists in your code. But since you are asking, I assume the answer is “no”.

You can get that functionality in methods of GraphLinksModel: GetFromNodeForLink and GetToNodesForNode, and perhaps others that you care about. Just remember that everything that the GraphLinksModel deals with is app model data, not FrameworkElements such as Node and Link.

Those model methods are what the Diagram and Node and Link classes use to find out what relationships there really are.

Ok, so I was able to finally find selectedLink.FromNode.LinksConnected. I want to be able to show the values on all the links as you can see below there is only one link showing the value (the values will all be the same). I am interating through each selectedLink.FromNode.LinksConnected and calling link.Remeasure. This does not work. Is there something else that I can do to get these other links to show the values short of reloading the whole screen to do so?

Are you saying that your LinkTemplate doesn’t have TextBlock labels, and that you are adding new TextBlocks programmatically? Or that they are present (both in the DataTemplate and in the Links of the Diagram) but with no visibility? Or maybe something else?

The TextBlocks are there and when the screen is reloaded, the values show on all the links. I am using a visibility converter to show/not show the values based on selection in a context menu. The problem with reloading the whole screen is the performance hit and if it is not needed, it would be much cleaner to just call link.Remeasure or something similar. Or a relink?

It sounds like there’s a problem with your Visibility Binding.

When I inspect the values associated with each of the selectedLink.FromNode.LinksConnected, all of them show true in relation to showing values. It appears that the UI is not redrawing or remeasuring each link. Can I someone redraw those links? I tried link.IsSelected = true, then link.Remeasure to no avail.

So you were looking at the TextBlock.Visibility for each TextBlock acting as a label in your Link DataTemplate, for each Link that is connected with that Node?

Is there a way that I can capture the context menu closing event in the .xaml.cs file?

There are various choices – consider the Closed event or the ContextMenuClosing event on the FrameworkElement with the menu. Nothing with context menus has anything to do with diagrams, so you should be able to search the web for help.

Ok I am successfully capturing the context menu closing event. Is there some way that I can access those textblocks directly to make them visible through the part manager or link template? Link.Remeasure will work to select all the associated links in the .xaml.cs, so I thought that maybe that would work for the Visibility property as well and it is not. It only seems to work for the selected link and not the others.

You could x:Name them and find them with Part.FindNamedDescendant(String).

I finally got it!!! In the .xaml.cs, after capturing the context menu closing event, I am calling the PartManager.RebuildLinkElements(); I did not see that before and I felt like I had looked everywhere…