AnsweredAssumed Answered

MapView.GetOverlayControls returns wrappers instead of added controls

Question asked by maxmaxmaxmaxmax on May 7, 2019
Latest reply on May 9, 2019 by cmacleod-esristaff

Let's see an example:

 

var mapToolsOverlayControl = new MapToolsOverlayControl
{
    DataContext = new MapToolsOverlayControlViewModel()
};

MapView.Active.AddOverlayControl(mapToolsOverlayControl);

 

Then if I call MapView.Active.GetOverlayControls(), I'll get objects of these types:

 

ArcGIS.Desktop.Internal.Mapping.Controls.MapCreditsControl
ArcGIS.Desktop.Internal.Mapping.Controls.AirspaceControlWrapper

 

Where is my MapToolsOverlayControl?

 

Inspecting things with reflection I found that GetOverlayControls returns UIElements that has UserControl property. So I'm able to find my control with reflection. But why it is wrapped to some internal class (AirspaceControlWrapper)? It's not what user expects from AddOverlayControl.

 

If you need to wrap added control for some reason, please return new object from AddOverlayControl and give a remark in docs with snippet of how to get a control after it's added on map.

Outcomes