UnGroupElements Method (GraphicsLayerExtensions)
Ungroup the elements contained in 'groups'.
This method must be called on the MCT. Use QueuedTask.Run.
Un-Group Graphic Elements
var selectedElements = graphicsLayer.GetSelectedElements().ToList(); ;
if (selectedElements?.Any() == false)//must be at least 1.
return;
var elementsToUnGroup = new List<GroupElement>();
//All selected elements should be grouped.
if (selectedElements.Count() == selectedElements.OfType<GroupElement>().Count())
{
//Convert to a GroupElement list.
elementsToUnGroup = selectedElements.ConvertAll(x => (GroupElement)x);
}
if (elementsToUnGroup.Count() == 0)
return;
//UnGroup
graphicsLayer.UnGroupElements(elementsToUnGroup);
Target Platforms: Windows 11, Windows 10
ArcGIS Pro version: 3.0 or higher.