Question about controling node location

Hi,

In ForceDirectedLayout, I want to control one node’s location. First I override IsFixed method to fix that node. Then I use the typical
go:Node.Location ="{Binding Data.Location, Mode=TwoWay}"
to bind the location to my model. I also set both HorizontalContentAlignment and
VerticalContentAlignment on the diagram to Stretch to avoid any auto adjustment.

So when I change the node’s location in code (say 0,0) , the diagram moves properly. So far so good. Now I enlarge the window and reset the node to (0,0). I expect that node will move the new center of the window. Instead, it stays where it was.

How can I accomplish that?

BTW, I don’t set HorizontalContentAlignment and VerticalContentAlignment to Center because I don’t like the sudden shift effect of the diagram after layout is finished. I implement my own animation to place the my model root at the center, which is not exactly the same as “Center” but it’s good enough for me.

Thanks.

You want (0,0) to be in the center of the viewport? You’ll need to set the myDiagram.Panel.Position appropriately to be the top-left corner point so that the center of the panel is (0,0) at the current scale.

In version 1.1 we will have added a DiagramPanel.CenterPart method to do exactly that. There’s a recent topic in this forum about that.

Depending on the size of the diagram contents, it might not be able to scroll that far – you may need to increase the DiagramPanel.Padding or increase the DiagramPanel.DiagramBounds.

Thanks, setting Panel’s Position works for me.