Hello,
I’m trying to set Group Location inside a group (overriding DoLayout()) programmatically.
All Groups may contains themselves more Groups .
When Groups are expanded is first called the layout DoLayout() of the children and then there from the parent.
Problem is that I’m not able to have parent Group where it should be,
Should I use ArrangementOrigin to set Groups Location inside the Layout?
if yes how to set/get correctly the Layout ArrangementOrigin properties of the group as the template contains more Visual element stacked ? Is there an easy way to get the layout Location inside the template? How to makes Group inside a layout group moved with their parent when DoLayout from the parent is called?
The location of any Node, including any Group, is determined by the layout that is responsible for positioning the node. For a top-level Group, that would be the Diagram.Layout; for a nested Group that would be the containing Group’s Group.Layout.
This is Ok but what about layout inside another Layout. When I set Location of Node inside a children Layout, which value should I take as ArrangementOrigin (for all different Layout).
Node/Group is an Absolute position in the diagram, Right?.
My problem is when I set the position of child Group, position of the parent is no more correct here an example:
Only parent
With a child:
Does your Group template have a GroupPanel? If so and if there is no layout positioning the group, the group will get its location from where its members are. But if there is a layout positioning the group, it will move that node (which happens to be a group) to where it thinks that node should be. That would include moving that group’s members.
In your case, are “Node1” and “Node2” top-level nodes? If so, is there a Diagram.Layout, and how is it declared?
Yes Group template have a GroupPanel (see below template implementation)
Diagram have a self implemented layout.
For the moment I simply put all root (top-level) group side by side.
Layout inside the group panel do the same.
Here my Group template implementation (same for all Group):
A Remark, when I used CircularLayout with only 1 node there’s no refresh when I add a new node to le collection of the nodes. It works fine when there is at least 2 Nodes (is this a Bug? I’m using GoWPF v2.2.4.45)
I find that CircularLayout works correctly when there is just one node or when there are just two nodes. (In the latter case it just positions the nodes next to each other.)
Why would you be calling DoLayout on the value of Diagram.Layout? Are you executing a transaction for each time that you add (or remove) a collection of nodes? A transaction will automatically make sure that if the layout has been invalidated that it is performed again at the end of the transaction.