Subscribe to Map Change Event

706
1
05-21-2019 10:27 AM
SusanFarley
New Contributor III

Our application does analysis on the current map. When the user clicks on the button to start up our tool, we have the code:

     var mv = MapView.Active;

     MainWindow frm1 = new MainWindow();

     frm1.MainMapView = mv;

Where MainWindow is where the use can run different analysis. This works great till the user either loads a new project or goes to another map in the current project. The variable mv is understandably still referencing the original active map if the user has not closed the MainWindow. Is there a way to capture the event when the map or project does change?

I think this might be similar to: https://community.esri.com/thread/226083-notification-of-active-edit-template-change, but there was no response to it.

Thank you,

Susan

Tags (2)
0 Kudos
1 Reply
UmaHarano
Esri Regular Contributor

Hi Susan

To see if the Active Map view changed in Pro, you can subscribe to the ActiveMapViewChangedEvent

To see if a new project was opened, you can subscribe to the ProjectOpenedEvent

I think these are the events you are looking for.

Thanks

Uma