How can I select a layer and open its Layer Property window programetically in ArcGIS Pro SDK?

731
3
11-20-2017 09:53 PM
SuryakantUpadhayay
New Contributor II

How can I select a layer and open its Layer Property window programetically in ArcGIS Pro SDK?

Tags (1)
0 Kudos
3 Replies
NarelleChedzey
Esri Contributor

Try this, 

// change this to get the appropriate layer you want
var layer = MapView.Active.Map.GetLayersAsFlattenedList().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);

SuryakantUpadhayay
New Contributor II

Hi,

Thanks for the solution. Its working. I was using same approach to select layer on map.

After selection I tried PropertySheet.ShowDialog method. Thus I was able to open layer properties dialog but page binding was not happening.

I tried passing DAML id of layer property sheet then null for default page and Layer which is selected as a object parameter.

Any Idea if I want to use that approach what parameters to pass for page binding? I know that PropertySheet is mainly used for customization but I was wondering if I can pass some parameter for layer page binding to make that working.

0 Kudos
SuryakantUpadhayay
New Contributor II

The reason behind why I want to use property sheet is that I want to programatically open Layer properties window and programetically close that too after its opened. I am actually measuring time to open and close the layer property window.

0 Kudos