Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am using IGraphicsContainerEvents_ElementAddedEventHandler to do stuff with graphics added by users in an ArcMap session using the standard drawing toolbar. As the code snippet below shows, its a pretty straight-forward process, and works perfect for the first few (2-3) graphics added. However, eventually 'ElementAdded' stops firing for no apparent reason (i.e no errors that I can catch).

Does anyone have any idea of what would be unregistering the listener (OnElementAdded) and/or preventing the ElementAdded event to be fired?

ICompositeGraphicsLayer activeGraphicsLayer = (ICompositeGraphicsLayer)mxDoc.ActiveView.FocusMap.ActiveGraphicsLayer;
IGraphicsContainerEvents_Event containerEvents = (IGraphicsContainerEvents_Event)activeGraphicsLayer;
containerEvents.ElementAdded += new IGraphicsContainerEvents_ElementAddedEventHandler(OnElementAdded);

private void OnElementAdded(IElement Element)
{
// do stuff
}
share|improve this question
2  
Are you re-wiring this event handler when the active view changes? –  Kirk Kuykendall Mar 13 '12 at 16:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.