Nodes moving to left top corner when deserialized


#1

Hi,

I have a diagram and I drag and drop a node over the diagram and it is at location (x,y) and then I save the content of the diagram. When I read the same file and populate the diagram the node appears at the same location but the diagram is focused such a way that the aggregates appears at left top corner i.e (x,y) itself is moved to left top corner. I don’t want to have this kind of focus/pan. How can I do it ?

Thanks


#2

It sounds like you want to save and restore the value of DiagramPanel.Position.

Due to the many things that happen asynchronously when initializing a diagram, including loading a model, you’ll need to make sure you restore the value of DiagramPanel.Position only at the end of a Diagram.InitialLayoutCompleted event. Or, if you don’t want to do that, set the value of Diagram.InitialPosition, which is used to set the DiagramPanel.Position at about the same time.