I'd like to create an ArcGIS Pro Add In that an event can be used to trigger some code execution when a layer is added to a map. Is this possible? I was unable to locate an event in the SDK, or I'm looking for the wrong thing. Thanks for your help.
Regards,
Frank
Solved! Go to Solution.
Hi Frank
You can use the LayerAddedEvent in the ArcGIS.Desktop.Mapping assembly.
The arcgis-pro-sdk-community-samples repo has a couple of samples that uses this event also.
Thanks
Uma
Hi Frank
You can use the LayerAddedEvent in the ArcGIS.Desktop.Mapping assembly.
The arcgis-pro-sdk-community-samples repo has a couple of samples that uses this event also.
Thanks
Uma
Hi Uma,
The LayersAddedEvent class worked. Thanks for the succession.
protected override bool Initialize()
{
ArcGIS.Desktop.Mapping.Events.ActiveMapViewChangedEvent.Subscribe(MapViewActivateEvent);
ArcGIS.Desktop.Mapping.Events.LayersAddedEvent.Subscribe(LayerAddEvent);
return true;
}
private void LayerAddEvent(LayerEventsArgs args)
{
try
{
foreach(var newLayer in args.Layers)
{
if (newLayer.Map == MapView.Active.Map && newLayer is BasicFeatureLayer)
{
updateEventLayers(newLayer);
//var layerAddString = "Layer added event";
//MessageBox.Show(layerAddString, "Caption");
}
}
}
catch (Exception ex)
{
var ErrorString = ex.Message;
//MessageBox.Show("An tttterror occurred while updating attribute column data " + ErrorString);
}
}