Create_Group_With_Single_Element_Root
//Create a group with a single element at the root level of the contents pane.
//Find an existing element
Element titleElm = layout.FindElement("Title") as Element;
//Construct on the worker thread
await QueuedTask.Run(() =>
{
//At 2.x - GroupElement groupWithSingleElementAtRoot = LayoutElementFactory.Instance.CreateGroupElement(layout, titleElm);
// groupWithSingleElementAtRoot.SetName("Group with single element at root");
GroupElement groupWithSingleElementAtRoot =
ElementFactory.Instance.CreateGroupElement(layout, new List<Element>() { titleElm }, "Group with single element at root");
});
Create_Group_With_List_Elements_Root
//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(() =>
{
//At 2.x - GroupElement groupWithListOfElementsAtRoot = LayoutElementFactory.Instance.CreateGroupElement(layout, elmList);
// groupWithListOfElementsAtRoot.SetName("Group with list of elements at root");
GroupElement groupWithListOfElementsAtRoot =
ElementFactory.Instance.CreateGroupElement(layout, elmList, "Group with list of elements at root");
});
Target Platforms: Windows 11, Windows 10
ArcGIS Pro version: 3 or higher.