Custom diagram layout

Hi

I'm using a custom layout for the diagram and the nodes are not maintaining the location to which it was moved while laying out. Below is expected and actual layout of the nodes: [code] Expected: [Head_Node (10, 10)] [Node1 (112, 10)] [Node2 (129, 10)] [Node3 (112, 50)] [Node3 (132, 50)]

Actual:
[Head_Node]
[Node1] [Node2]
[Node3] [Node3]
[/code]
The cordinates in the Expected layout are the values that I got while stepping through the DoLayout function code. The actual layout has cordinates different from the value assigned in the DoLayout function. The “Head_Node” has (46, 45) as the cordinate instead of (10, 10) assigned in the layout function.

The process of laying the nodes is as follow:

> Group nodes by type, get the Head_node
> Set Head_node to initial position (10, 10)
> Set nx = 10 + Head_Node.Bounds.Width + NodeSpacing, ny = 10
> y = ny
> Foreach group in Groups
   * x = nx
   * Foreach node in group
      - Set node's position to (x, y)
      - set x = node.Bounds.Width + NodeSpacing
   * y += (max height of node in the group) + Node Spacing
> Call base.DoLayout

I’m using GraphModel for Diagram’s Model. Is there anything I need to do so that the location of nodes doesn’t change?

Silverlight 4, goSilverlight 1.2.6.4

Thanks.

Try not calling base.DoLayout.

I tried it. But, didn’t work. I even looked at the TableLayout in the demo. Its almost same except for logic for determining the node’s location on the diagram.

Well, judging from your pseudocode, the call to base.DoLayout was the only obvious potential problem.

Is an instance of your layout class the value of Diagram.Layout?

Have you customized the Diagram.LayoutManager at all? (One doesn’t normally need to.)

Is the Location of the “Head_Node” the only problem?

Yes, I assign instance of CustomLayout to diagram.Layout.

No, I’ve not customized the Diagram.LayoutManager. If need be, what are the settings or properties I need to edit so I can try to rectify the problem?

Yes, the location of the “HeadNode” is the only problem. I’m not able to control the nodes position.

And you’re sure you don’t set the “Head_Node”'s Location twice?

Yes. Once the Head_Node’s location is set it isn’t referred anymore (directly or indirectly)

Have you set the Group.Layout to null?
It seems the layout of each group is not needed because you are assigning the locations of all non-Group nodes.

Diagram layout is the only time GoXam would be setting the Node.Location for any node.
But because you have replaced the Diagram.Layout and Group.Layout properties, there’s no GoXam code that is setting any node location.

So I would step through your layout code to see if it’s setting anything to be at (46, 45).

No, I’ve not set Group.Layout. By group I mean, logical grouping which I do by using Dictionary<group_name, List> (sorry for the confusion). For each node in the logical group I layout nodes as mentioned in the code.

OK, so the “Head_Node” node is not part of any of your groups, and you aren’t using GoXam Groups at all.

Correct

So you are not setting the Node.Position or Node.Location anywhere else.

Do you have a data-binding on the “Head_Node”'s Node.Location, and this is how you are setting the location? If so, is it OneWay or TwoWay? If it’s TwoWay, try it OneWay. If it’s OneWay, can you make sure the data property isn’t being changed in any other manner?