//Create an empty group element at the root level of the contents pane
//Create on worker thread
await QueuedTask.Run(() =>
{
GroupElement grp1 = LayoutElementFactory.Instance.CreateGroupElement(layout);
grp1.SetName("Group");
});
// *** or ***
//Create a group element inside another group element
//Find an existing group element
GroupElement existingGroup = layout.FindElement("Group") as GroupElement;
//Create on worker thread
await QueuedTask.Run(() =>
{
GroupElement grp2 = LayoutElementFactory.Instance.CreateGroupElement(existingGroup);
grp2.SetName("Group in Group");
});
//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;
//Construct a list and add the elements
List<Element> elmList = new List<Element>
{
scaleBar,
northArrow,
legend
};
//Perform on the worker thread
await QueuedTask.Run(() =>
{
GroupElement groupWithListOfElementsAtRoot = LayoutElementFactory.Instance.CreateGroupElement(layout, elmList);
groupWithListOfElementsAtRoot.SetName("Group with list of elements at root");
});
// *** or ***
//Create a group using a list of element names at the root level of the contents pane.
//List of element names
var elmNameList = new[] { "Table Frame", "Chart Frame" };
//Perform on the worker thread
await QueuedTask.Run(() =>
{
GroupElement groupWithListOfElementNamesAtRoot = LayoutElementFactory.Instance.CreateGroupElement(layout, elmNameList);
groupWithListOfElementNamesAtRoot.SetName("Group with list of element names at root");
});