Reading and Writing Diagram with SubGraphs

What is the best way to save and restore a diagram that may contain subgraphs? I've tried various approaches, but all fall short. Here's my strategy so far.

I have an object model with nodes attached to objects. I’m using the PartID mechanism to reassociate the objects with the appropriate nodes after reading in the diagram and the objects from the file stream.

Everything seems to work after the file is reloaded, except that the subgraphs do not contain any nodes. Instead, they just float on the canvas as separate objects without any links attached. I’m subclassing the GoSubGraph.

One question I have is when using the GoXmlBindingTransformer, must I add a binding for ALL properties of the derived class?

The GoXmlBindingTransformer for a GoSubGraph will look something like this:

  GoSubGraph sg = new GoSubGraph();
  sg.Port = new GoPort();
  t = new GoXmlBindingTransformer("SubGraph", sg);
  t.HandlesNamedPorts = true;  // generate attributes for each of the named ports, specifying their IDs
  t.HandlesChildren = true;  // generates children and consumes them by adding to the subgraph
  t.HandlesChildAttributes = true;  // make sure reading/writing each child calls these Generate/ConsumeChildAttributes methods
  t.HandlesSubGraphCollapsedChildren = true;  // generate SavedBounds and SavedPath info for children if subgraph is collapsed
  t.AddBinding("Text", "Text");
  t.AddBinding("xy", "Position");

must I add a binding for ALL properties of the derived class

only the ones you want saved/restored. If the object you pass into the GoXmlBindingTransformer has some properties set (e.g. Shape.BrushColor = blue) then you don’t need to save / restore that.

A common problem is that people try to save too much. (for example Position, Location, X, Y, Width, Height, Bounds)