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

In This Topic
    SelectLayers Method
    In This Topic
    Selects layers in the TOC.
    Syntax
    Public Sub SelectLayers( _
       ByVal layers As IReadOnlyCollection(Of Layer) _
    ) 
    public void SelectLayers( 
       IReadOnlyCollection<Layer> layers
    )

    Parameters

    layers
    Example
    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());
    }
    Select a layer and open its layer properties page
    {
      // select it in the TOC
      List<Layer> layersToSelect = [featureLayer];
      MapView.Active.SelectLayers(layersToSelect);
    
      // now execute the layer properties command
      var wrapper = FrameworkApplication.GetPlugInWrapper("esri_mapping_selectedLayerPropertiesButton");
      var command = wrapper as ICommand;
      if (command == null)
      {
        // the command is not found, leave
      }
    
      // execute the command
      if (command.CanExecute(null))
        command.Execute(null);
    }
    Requirements

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

    ArcGIS Pro version: 3.0 or higher.
    See Also