Palette to Diagram: Transactions


Whenever I'm adding a node to the diagram by drag-n-drop from the palette, I'm getting this message in the console:

“Model changes should occur within a transaction – call StartTransation and CommitTransaction”

Where/when should I call the StartTransaction & CommitTransaction?

Another issue is, whenever a new node is added to the diagram, I check if the node of same type has already been added. If so, model.Undo function is called. This is working fine. The problem is, icon of the node as displayed in the palette is visible in the diagram.

I’m using diagram in tabs, if I switch to another diagram & switch back to it, the icons are not displayed. How do I prevent the icon from being displayed?

I’m using GoXam for WPF

Thank you.

I don’t know enough about your application to be able to identify what might be causing any problem.

Just drag-and-dropping a node from a Palette to a Diagram doesn’t result in warning messages in the sample apps that make use of Palettes.

When are you detecting that a new node has been added to the diagram?

If you are doing so in a Diagram.ExternalObjectsDropped event handler, I’m surprised that calling UndoManager.Undo() would work. Within the transaction, as that event handler is, you should call UndoManager.RollbackTransaction().

But if you are detecting the new node at some other time when a transaction is not ongoing, I suppose calling Undo() will work. But by then the DraggingTool should be all finished, so no temporary objects used during the drag should still be lying around.