AnsweredAssumed Answered

Display legend in dockable window

Question asked by jms143 on Oct 14, 2014

I'm trying to display a legend in a dockable window. I am successful in creating a legend in layout view using the code below. Is there anyway to draw 'MSElement' in a dockable window? Thanks.

 

 

ILegend legend = new LegendClass_2();
legend.AutoAdd = true;
legend.Title = "Test";
legend.Map = mxdoc.FocusMap;

IMapSurroundFrame MSFrame = new MapSurroundFrameClass();
MSFrame.MapSurround = legend;

IElement MSElement = MSFrame as IElement;
IEnvelope en = new EnvelopeClass();
en.XMin = 1.5; en.YMin = 1.5;
en.Width = 10; en.Height = 10;
MSElement.Geometry = en as IGeometry;

IGraphicsContainer gc = mxdoc.PageLayout as IGraphicsContainer;
gc.AddElement(MSElement, 0);
            
mxdoc.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphic
s, null, null);



Outcomes