ArcGIS Pro 3.2 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / GroupLayer Class
Members Example

In This Topic
    GroupLayer Class
    In This Topic
    Represents a layer containing an editable collection of layers.
    Object Model
    GroupLayer ClassLayer ClassStandaloneTable ClassCIMDataConnection ClassTimeExtent ClassCIMBaseLayer ClassSpatialReference ClassTimeParameters ClassMap ClassILayerContainer InterfaceEnvelope Class
    Syntax
    Remarks
    To create a GroupLayer, you must call CreateGroupLayer() method of the LayerFactory class, instead of directly using a constructor.
    Example
    Remove empty groups
    var map = MapView.Active.Map;
    if (map == null)
      return;
    //Get the group layers
    IReadOnlyList<GroupLayer> groupLayers = map.Layers.OfType<GroupLayer>().ToList();
    foreach (var group in groupLayers)
    {
      if (group.Layers.Count == 0) //No layers in the group
      {
        //remove the group
        await QueuedTask.Run(() => map.RemoveLayer(group));
      }
    }
    Inheritance Hierarchy

    System.Object
       ArcGIS.Desktop.Framework.Contracts.PropertyChangedBase
          ArcGIS.Desktop.Mapping.MapMember
             ArcGIS.Desktop.Mapping.Layer
                ArcGIS.Desktop.Mapping.CompositeLayer
                   ArcGIS.Desktop.Mapping.CompositeLayerWithTables
                      ArcGIS.Desktop.Mapping.GroupLayer

    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also