I created a GroupElement with layout elements such as text, legend, scalebar to find the bounds of all graphic elements except the map frame.
GroupElement allElements = LayoutElementFactory.Instance.CreateGroupElement(layout, layout.Elements);
I see this Element in the content pane. Now I just want to ungroup this GroupElement but I just can't find a way to do it by code.
There is the function to ungroup a GraphicsLayer in the map but this is not a graphics layer in the map, it is a GroupElement in the Layout.
Please help me.
Thanks
Myriam
Solved! Go to Solution.
For anyone who is also thinking in the wrong direction, I found the solution: The elements have to be "ungrouped" in the TOC. First they have to be reversed to maintain the same order in the TOC as before they were grouped.
if (group != null)
{
group.Elements.Reverse();
foreach (var item in group.Elements)
{
item.SetTOCPositionAbsolute(layout, true);
}
var groupToDelete = layout.FindElement(group.Name);
layout.DeleteElement(groupToDelete);
}
For anyone who is also thinking in the wrong direction, I found the solution: The elements have to be "ungrouped" in the TOC. First they have to be reversed to maintain the same order in the TOC as before they were grouped.
if (group != null)
{
group.Elements.Reverse();
foreach (var item in group.Elements)
{
item.SetTOCPositionAbsolute(layout, true);
}
var groupToDelete = layout.FindElement(group.Name);
layout.DeleteElement(groupToDelete);
}