Report Inappropriate Content
Top Print
This Forum is closed for replies.
|
| Subject |
Re: MapControl loses ActiveView events after layers added |
| Author |
Randal Greene |
| Date |
Sep 21, 2009 |
| Message |
Did some more testing and it appears that adding the new layer was not what caused the events to unhook. Simply turning layers on/off and right-clicking them to show the context menu eventually caused the events to unhook.
So I did some more hunting on the forum here, and found several references to use of static variables. So I made the delegates static variables, and thought I had solved the problem entirely. But a few minutes ago, after a relatively long test session, the ActiveView events became unhooked!
Any thoughts appreciated... |
| |
static IActiveViewEvents_ContentsChangedEventHandler m_ContentsChangedEventHandler;
static IActiveViewEvents_ItemAddedEventHandler m_ItemAddedEventHandler;
private void m_AxMapControl_OnMapReplaced(object sender, IMapControlEvents2_OnMapReplacedEvent e)
{
m_ContentsChangedEventHandler = new IActiveViewEvents_ContentsChangedEventHandler(m_AxMapControl_ActiveView_ContentsChanged);
((ESRI.ArcGIS.Carto.IActiveViewEvents_Event)(m_AxMapControl.ActiveView)).ContentsChanged += m_ContentsChangedEventHandler;
m_ItemAddedEventHandler = new IActiveViewEvents_ItemAddedEventHandler(m_AxMapControl_ActiveView_ItemAdded);
((ESRI.ArcGIS.Carto.IActiveViewEvents_Event)(m_AxMapControl.ActiveView)).ItemAdded += m_ItemAddedEventHandler;
} |
| |
|