ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / Map Class / Layers Property
Example

In This Topic
    Layers Property (Map)
    In This Topic
    Gets a read-only collection of layers from the layer container.
    Syntax
    Example
    Obtaining Geodatabase from FeatureLayer
    {
      await QueuedTask.Run(() =>
      {
        IEnumerable<Layer> layers =
          MapView.Active.Map.Layers.Where(layer => layer is FeatureLayer);
    
        foreach (FeatureLayer featureLayer in layers)
        {
          using (Table table = featureLayer.GetTable())
          using (Datastore datastore = table.GetDatastore())
          {
            if (datastore is UnknownDatastore)
              continue;
    
            Geodatabase geodatabase = datastore as Geodatabase;
          }
        }
      });
    }
    Select all feature layers in TOC
    {
      //Zoom to the selected layers in the TOC
      var featureLayers = mapView.Map.Layers.OfType<FeatureLayer>();
      mapView.SelectLayers(featureLayers.ToList());
    }
    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also