ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / MapView Class / GetSelectedLayers Method
Example

In This Topic
    GetSelectedLayers Method
    In This Topic
    Returns the collection of layers selected in the TOC.
    Syntax
    Public Function GetSelectedLayers() As IReadOnlyList(Of Layer)
    public IReadOnlyList<Layer> GetSelectedLayers()

    Return Value

    The collection of layers selected in the TOC.
    Example
    Zoom To Selected Layers
    {
      //Zoom to the selected layers in the TOC
      var selectedLayers = mapView.GetSelectedLayers();
      mapView.ZoomToAsync(selectedLayers);
    }
    Pan To Selected Layers Asynchronous
    {
      //Pan to the selected layers in the TOC
      var selectedLayers = mapView.GetSelectedLayers();
      mapView.PanToAsync(selectedLayers);
    }
    Requirements

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

    ArcGIS Pro version: 3.0 or higher.
    See Also