AnsweredAssumed Answered

SelectionChanged event not firing

Question asked by stefda on Jun 1, 2015
Latest reply on Apr 7, 2016 by Xhosa

I want to bind an action to the SelectionChanged event on the map. In the extension, I bind the action to the focused map's SelectionChanged event upon firing ArcMap.Events.NewDocument and ArcMap.Events.NewDocument. The assumption I'm making here is that upon firing of the New(Open)Document events, there is an active document with a map so I can indeed bind actions to its events. But it doesn't work.


What is the correct way of getting this to work?


using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using ESRI.ArcGIS.ArcMapUI;
using ESRI.ArcGIS.Carto;

namespace BaseAddin {

    public class BaseExt: ESRI.ArcGIS.Desktop.AddIns.Extension {

        public BaseExt() {

        protected override void OnStartup() {

        private void WireUpEvents() {
            ArcMap.Events.NewDocument += ArcMap_NewOpenDocument;
            ArcMap.Events.OpenDocument += ArcMap_NewOpenDocument;

        private void ArcMap_NewOpenDocument() {

            IMxDocument doc = ArcMap.Document as IMxDocument;

            ((IActiveViewEvents_Event)doc.FocusMap).SelectionChanged +=
                new IActiveViewEvents_SelectionChangedEventHandler(delegate() {
                    System.Windows.Forms.MessageBox.Show("Feature selection changed.");