0

With ArcGIS Pro SDK 2.5, you can detect that the map selection has changed with the MapSelectionChangedEvent, which also includes selecting one or many rows in the attribute table of a geodatabase that is loaded in a MapView. I know that I can wire it up like:

private SubscriptionToken eventToken = null;

private void SetupEvents()
{
  eventToken = MapSelectionChangedEvent.Subscribe(OnMapSelectionChangedEvent);
}

private void OnMapSelectionChangedEvent(MapSelectionChangedEventArgs obj)
{
  //do work on the selection
}

I would prefer to isolate the work in the handler to only happen when the geodatabase's attribute table row selection changes, not on all map selections. I haven't been able to find an event that fits this qualification in the sdk. Does one exist?

EDIT 3/19/2020: Since it may be unclear what I'm attempting to achieve, the below image has the MapView and the open attribute table. I would like for the selection of a row in that table to trigger an event in my add-in. The MapSelectionChangedEvent is far too broad for this purpose, so if there is a SelectionChanged event or the like on the attribute table that I can hook into, that would work. I cannot seem to find one, though. I can select something from the add-in and have it show on the map, but I wanted to know if something existed on this built in control.

enter image description here

0

After contacting ESRI Support, there is no way to actually achieve this through a singular event, but you can do them by continuously subscribing and unsubscribing.

The suggested approach was:

   private SubscriptionToken eventToken = null;

   private void SetupPaneEvent()
   {
      eventToken = ActivePaneChangedEvent.Subscribe(OnActivePaneChangedEvent);
   }

   private void OnActivePaneChangedEvent(PaneEventArgs args)
   { 
      //The pane that is selected is a table, so then register an event 
      //that handles selections
      if (FrameworkApplication.Panes.ActivePane is ITablePane)
      {
         eventToken = MapSelectionChangedEvent.Subscribe(OnMapSelectionChangedEvent);
      }
      else
      { 
         // not a table?  Unsubscribe.
         MapSelectionChangedEvent.Unsubscribe(eventToken);
      }
   }

   private void OnMapSelectionChangedEvent(MapSelectionChangedEventArgs args)
   { 
      //Do work that detects which source and how you need to filter out different 
      //actions between feature classes and stand alone tables
   }
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.