I am attempting to migrate a Pro AddIn from 2x to 3x and ran into an issue.
My addin uses the MapSelectionChangedEvent to capture selected features in order to obtain wkts associated with these features. This is the code used to subscribe the selection event:
ArcGIS.Desktop.Mapping.Events.MapSelectionChangedEvent.Subscribe(OnSelectionChanged);
private async void OnSelectionChanged(ArcGIS.Desktop.Mapping.Events.MapSelectionChangedEventArgs args)
{
if (args == null)
return;
var sel = args.Selection.ToDictionary();
// remove old wkts
components.Clear();
// get the first BasicFeatureLayer
//var member = sel.Keys.FirstOrDefault(mm => mm is BasicFeatureLayer);
foreach (var member in sel.Keys)
{
********
These code work fine in 2x but after migration to 3x the OnSelectionChanged method does not run even after selections were made on the map.
The migration guide did not mention any changes to events. The Migration Status Report does not mention anything useful.
You might check your namespaces, there is a new OnSelectionChange() method added at Version 3.0 to ArcGIS.desktop.Framework.Contracts and System.Windows.Controls.Primitives that is available for several of the controls (e.g., SearchTextBox,, ComboBox, etc.). These were not available at 2.9 and prior. They could be 'masking' your call.
Do you need a override modifier? The override modifier is required to extend or modify the abstract or virtual implementation of an inherited method, property, indexer, or event.
I can get the event to fire now but only if I make the feature selection in the attribute table. If I select on the map it still doesn't work. Why might that be?
I think I got it now. Thanks.
please post your solution 🙂
The events were actually firing. I just did not click on 'Select' button before clicking on map features.