Select all feature layers in TOC
public void SelectAllFeatureLayersInTOC()
{
//Get the active map view.
var mapView = MapView.Active;
if (mapView == null)
return;
//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
// get the layer you want
var layer = MapView.Active.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault();
// select it in the TOC
List<Layer> layersToSelect = new List<Layer>();
layersToSelect.Add(layer);
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)
return;
// execute the command
if (command.CanExecute(null))
command.Execute(null);
Target Platforms: Windows 11, Windows 10
ArcGIS Pro version: 3 or higher.