UndoManager cleared after first node added

I’m using GoXam for WPF 1.3.5 and I’ve noticed that my UndoManager is cleared after the first node is added. I’m starting with an empty diagram and creating it using drag and drop. However, my drag source is not a GoXam control so that logic is fairly custom and is based around the Diagram.Drop event. So what happens is:

  1. I create a new diagram with an empty model. The value of Diagram.Panel.DiagramBounds is {0,0,0,0}.
  2. The Diagram.InitialLayoutCompleted event is raised and the UndoManager is cleared.
  3. I add a node which results in commiting a custom transaction that contains a call to Model.AddNode.
  4. The Diagram.InitialLayoutCompleted is raised again and the UndoManager (which now has one compound edit) is cleared again.
My diagram has HorizontalContentAlignment and VerticalContentAlignment both set to Stretch and I'm using the default DiagramLayout. (I tried setting Diagram.Layout to x:Null in XAML, but that had no effect.) I tried setting LayoutManager.Initial to None and ValidateAll, but the UndoManager was still cleared.

What am I doing wrong here?

I just tried an application that started with an empty model and set a breakpoint on UndoManager.Clear. It was only called by the InitialLayoutCompleted event when the model was empty, not after adding a node dropped from a Palette.

My guess is that you are initializing the Diagram.Model or the Diagram.Model.NodesSource more than once. Or less likely, changing critical model properties (the “…Path” properties) after the Diagram is already using the model.