SubGraph Links In Front Of Nodes

I am prototyping a set of serialization routines which allow me to save/restore subgraphs. As part of this I loop through the nodes expressed in XML, instanciate those nodes, and add them to the given subgraph. After that, I loop through the links (labeled links) expressed in the XML and create links between nodes in the subgraph.
The associated logic works fine. I am able to interate through and create the given nodes, iterate through and create the given links. The problem that links appear “on top” of nodes that they “pass through”. For the main view I use the following code to ensure that links appear “behind” nodes they pass through:
this.GoView1.Document.LinksLayer = this.GoView1.Document.Layers.CreateNewLayerBefore(this.GoView1.Document.Layers.Default);
Is there something similar for subgraphs?

After spending some time debugging, I noticed that I was adding the links to the subgraph using “sg.Add(link)”. I changed the code to add the links to the Document rather than the subgraph. Once I changed this to a “sg.Document.Add(link)”, the links were traversing “behind” nodes instead of “on top” of nodes.
Still one problem… These links are set as selectable/deletable. However, when I try to click on one of the links within the newly created subgraph, the click seems to go to the subgraph rather than the link. The net effect is that I am unable to select the given links so that I can delete them. I’m pretty sure that this is because from a layers perspective, the links are “behind” the entire subgraph. Is there a simple way around this?

Instead of calling just sg.Add(link), you could have the links be owned by the subgraph and yet appear behind the nodes in the subgraph by inserting them to be first in the Z-order defined by the subgraph (actually by all GoGroups):
sg.InsertBefore(null, link)
When the links are not part of the subgraph and the user doesn’t seem able to pick them, perhaps it is because GoSubGraph.PickableBackground is true. Maybe setting that to false will get the effect you want.

Thanks Walter, I have been out of the office and just got back to this. Setting pickable background to false is an option; however, I am currently overriding the subgraph’s OnGotSelection to create a visual indicator (backgound color change) that the given subgraph is selected… If I set PickableBackground to false, will OnGotSelection only fire if the subgraph label text is selected?

GoObject.OnGotSelection is called when that GoObject is added to a GoSelection collection. That won’t change based on how an object might be selected – i.e. whether clicking in the “background” of a subgraph will cause the subgraph to be selected.