[Solved] Location of dynamically created node

Hi,

I'm adding nodes dynamically (within the transaction) to the diagram. After adding the nodes I update the position of the nodes (arrange it).

The problem is the “Location” value is updated to the value that I’ve set. But, in the diagram, the nodes are positioned @ the location “0, 0”.

Since, the application has multiple diagrams using tabs; if I switch to another diagram & come back, the nodes are displayed @ the right location. So, I used diagram_object.LayoutDiagram() to update the diagram after adding the nodes & specifying the location for the same. Still I’ve the same problem.

For debugging purpose, the node tooltip shows the location information; which is correct. But on the diagram it is placed at (0,0) point

Please help me in this regard.

Snapshot:

Initial position:

Before%20Switching%20Backn%20forth

After Switching to another tab & switch back: After%20swithcing%20back%20n%20forth
I missed this one:

When node is added to the model, node’s location is (0,0). After node is added to the model, I parse all the nodes & change their location value. What do I need to do in order to update the diagram after the location value has changed? As mentioned before I tried using LayoutDiagram but didn’t work.

Thanks, Sunil Kumar

I’m curious why the other two nodes are being positioned correctly for you.

Are you using different DataTemplates?
Do they all data-bind the go:Node.Location with Mode=TwoWay?
That way any positioning by layouts or by user dragging will be remembered.

Also, exactly which platform and DLL version are you using?

Hi Walter,

Platform is: WPF, .Net 4 GoXam version: 4.0.30319
I'm only arranging new nodes that are added. The other nodes were present before adding new nodes. Hence, they are positioned correctly.

The new nodes added are always placed on the right side of the second node (square one).

Yes, they are using different data templates. And their Location is set to TwoWay mode.

Are you just setting the Node.Location within the transaction?

Yes. It didn’t work.

Here is code structure:

StartTransaction
Add new nodes to the model
EndTransaction

StartTransaction
Set Location of the new nodes that are added
EndTransaction

I just tried the situation you describe, and I’m unable to reproduce any problem.

I tried setting the Node.Location in the second transaction. I also tried setting the nodedata property that the go:Node.Location was data-bound to. Both did what one would expect.

I also tried not setting the location at all. The default Diagram.Layout placed the new node at 0,0. This agrees with the behavior you are seeing.

What’s your go:Node.Location data binding? What’s the value of your Diagram.Layout?

The Location binding is:

go:Node.Location="{Binding Path=Data.Location, Mode=TwoWay}"

I’m using the default layout… i.e. I haven’t set the layout.

What four-part version of GoWpf are you using?

Is the Diagram inside a TabControl?

Try simplifying as much as possible. It appears that you shouldn’t be doing anything w.r.t. diagram layout.

The diagram is within the tabcontrol

As per your suggestion… I’m using the TreeLayout now. The problem is solved. I’ve even removed the code for arranging the node.

Thanks alot for your help.