Select to view content in your preferred language

AddOverlayControl not adding to MapView

472
2
Jump to solution
11-28-2024 06:58 AM
CarstenAndersson
Regular Contributor

I want to add a standard Slider control (System.Windows.Controls.Slider) as an overlay control in the active map view. My code is quite simple, but nothing is added to the map view and no exception is raised. Here's the code:

 

var sliderControl = new Slider
{
    Minimum = 1,
    Maximum = 10,
    Width = 400,
    Value = 1,
    Height = 40,
    Visibility = System.Windows.Visibility.Visible
};
var mapViewOverlayControl = new MapViewOverlayControl(sliderControl, true, false, false, OverlayControlRelativePosition.BottomCenter, .5, .8);
MapView.Active.AddOverlayControl(_mapViewOverlayControl);

 

Not sure what I'm doing wrong. Any help would be greatly appreciated.

Regards

Carsten

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
GKmieliauskas
Esri Regular Contributor

Hi,

You have global variable _mapViewOverlayControl (with underscore) which is null, I think. So change it to:

MapView.Active.AddOverlayControl(mapViewOverlayControl);

Without underscore it works fine

View solution in original post

0 Kudos
2 Replies
GKmieliauskas
Esri Regular Contributor

Hi,

You have global variable _mapViewOverlayControl (with underscore) which is null, I think. So change it to:

MapView.Active.AddOverlayControl(mapViewOverlayControl);

Without underscore it works fine

0 Kudos
CarstenAndersson
Regular Contributor

Of course. How could I miss that?! Thanks a lot 🙂

0 Kudos