Wrong group node size


When a node within a group has links, the group size changes according to the size of the node + its links.

I need the group just to contain the node itself without its links. I tried to set the link in a different layer, but it doesn’t have any effect.

Screenshot of the current state:

As you can see the group node is far too wide (the height is not affected because it’s binded to a special converter which calculates it according to the number of child nodes).

Is there any way i can tell it to ignore the linked link parts when calculating the group node size?



Well, you could customize the GroupPanel class.

Here’s the standard definition of GroupPanel.ComputeMemberBounds, with the code to include the links removed:

protected override Rect ComputeMemberBounds() { Group sg = Part.FindAncestor<Group>(this); if (sg == null) return new Rect(); double minx = Double.MaxValue; double miny = Double.MaxValue; double maxx = Double.MinValue; double maxy = Double.MinValue; foreach (Node m in sg.MemberNodes) { if (m.Visibility != Visibility.Visible) continue; Rect b = m.GetElementBounds(m.VisualElement); // support rotation of whole node if (b.Left < minx) minx = b.Left; if (b.Top < miny) miny = b.Top; if (b.Right > maxx) maxx = b.Right; if (b.Bottom > maxy) maxy = b.Bottom; } Rect result; if (minx == Double.MaxValue || miny == Double.MaxValue) { Rect sgb = sg.GetElementBounds(this); result = new Rect(sgb.X, sgb.Y, 0, 0); } else { result = new Rect(minx, miny, maxx-minx, maxy-miny); } return result; }
Caution: I haven’t tested this.

While you’re at it, you might as well customize this method even further to account for the desired height. That way you won’t need that custom converter and data-binding.

Great! as always - quick and helpfull Smile

Thanks Walter.