ArcGIS Pro 2.7 API Reference Guide
CreateGroupElement(ILayoutElementContainer,IList<Element>) Method
Example 

ArcGIS.Desktop.Layouts Namespace > IElementFactory Interface > CreateGroupElement Method : CreateGroupElement(ILayoutElementContainer,IList<Element>) Method
Layout or GroupElement
A list of layout elements.
Creates a group element from a list of elements. This method must be called on the MCT. Use QueuedTask.Run.
Syntax

Parameters

elementContainer
Layout or GroupElement
elements
A list of layout elements.

Return Value

Returns a GroupElement.
Exceptions
ExceptionDescription
This method or property must be called within the lambda passed to QueuedTask.Run.
Remarks
If the element container is a Layout then the element gets added to the root level of the layout TOC at the top most position. If the element container is a GroupElement then it gets added to the group at the topmost position.
Example
//Create a group with a list of elements at the root level of the contents pane.

//Find an existing elements
Element scaleBar = layout.FindElement("Scale Bar") as Element;
Element northArrow = layout.FindElement("North Arrow") as Element;
Element legend = layout.FindElement("Legend") as Element;

//Build a list and add the elements
List<Element> elmList = new List<Element>
{
  scaleBar,
  northArrow,
  legend
};

//Construct on the worker thread
await QueuedTask.Run(() =>
{
  GroupElement groupWithListOfElementsAtRoot = LayoutElementFactory.Instance.CreateGroupElement(layout, elmList);
  groupWithListOfElementsAtRoot.SetName("Group with list of elements at root");
});
Requirements

Target Platforms: Windows 10, Windows 8.1

See Also

Reference

IElementFactory Interface
IElementFactory Members
Overload List