Best Event when Diagram Changes


#1

I need to capture when anything changes in the diagram (adding a new node, deleting a node, adding a link, moving a node, etc.)

I was thinking LayoutUpdated but that seems like overkill (it fires like crazy).
Is there a better/recommended event to use or do I need to add code to all the different events that fire as a result of doing something?
Thanks-
Dave

#2

You could try using a Model.Changed event handler.

However, whether or not you will then get node Location changes depends on whether you have two-way data-binding on the Node.Location property. And similarly for other properties that the model does not know about.


#3

@walter, does Model.changed event also get triggered when layout of a diagram changes ?


#4

This is a GoXam question, not GoJS. Although the answer is vaguely analogous to one for GoJS.

The Diagram.LayoutCompleted event is best for that purpose.

The above mentioned LayoutUpdated event is on UIElement and has almost nothing to do with the contents of the Diagram.

The only reasonable and general way to get events about changes is to get them for the model, but as I said above, that depends on the state being in the model, normally via a TwoWay Binding.