Select to view content in your preferred language

Create a MapControl in UserControl

248
7
2 weeks ago
jefferson_bzp
New Contributor II

I'm trying to create a MapControl inside a UserControl like this:

XAML:

<mapControls:MapControl
Name="mapControl"
Grid.Row="1"
VerticalAlignment="Bottom"
HorizontalAlignment="Stretch"
Height="275"
ViewContent="{Binding Path=MapContent}" />

 

In my code I am using MapControlContentFactory.Create to create my map, however, the map is not rendered in the user control, but if I use a Pro Window and add the same XAML as above inside the Pro Window it works correctly.

Is MapControl supposed to not work in a UserControl and only inside the ProWindow or is it some kind of bug?

0 Kudos
7 Replies
UmaHarano
Esri Regular Contributor

@jefferson_bzp 

I am not able to repro this. I was able to host my MapControl inside a generic WPF UserControl. The active mapView rendered in this map control.

You can add a small addin with your workflow that illustrates the issue if you want. 

0 Kudos
jefferson_bzp
New Contributor II

@UmaHarano , 

Within the zip is the small Addin with the workflow. I've added two buttons to the Addin as you can see in the attached image, one opens user control and the other opens a pro window. The pro window displays the map, the user control does not though.

Thanks for the support.

MapControl.png

0 Kudos
UmaHarano
Esri Regular Contributor

Thank you @jefferson_bzp 

This sample helps me see the issue. Will post back with what I find.

GKmieliauskas
Esri Regular Contributor

Hi,

There is a ArcGIS Pro community sample with MapControl inside UserControl. OverviewMapControl sample is here. It works fine on ArcGIS Pro 3.2

0 Kudos
jefferson_bzp
New Contributor II

Hi @GKmieliauskas

It does work within a dockpane, but my intention is to add the user control that contains the MapControl as an overlaycontrol and this way the result is what we can see in the image I posted above. The map seems to be there but it is not being displayed, if you notice the button that shows the credits of the layer service is displayed, but where the map should be it is blank.

I did another test: I took the example you sent and added the UserControl (MapControlDockpaneView) as an overlaycontrol and the result was the same as in the example I sent. The interesting thing is that the map events remained working, so when I moved the extent in the blank window the main map was moved, i.e. the map is there as an overlaycontrol, but it is not possible to view it.

It seems that the problem is not the MapControl being inside a UserControl, but adding it as an overlaycontrol.

I found this note in the documentation:

NOTE - The is a native control and if it is placed in a transparent native window then the will also be transparent and will not display. An example of this is if you use the as an embeddable control by associating it with a then the will be hosted in a transparent native window and will not be visible.
ProConcepts Map Exploration · Esri/arcgis-pro-sdk Wiki · GitHub


If I don't change the background of my user control to white, the moment I add the user control as an overlaycontrol I get a transparent window, so is that the problem?

0 Kudos
UmaHarano
Esri Regular Contributor

@jefferson_bzp 

You found it!  That is the exact reason your MapControl is not seen on a MapViewOverlayControl or on a Embeddable control. 

Hosting the MapControl in an MapViewOverlayControl or an Embedded control is not supported. 

 

0 Kudos
jefferson_bzp
New Contributor II

Hi @UmaHarano , 

In terms of implementation, doesn't the magnifier tool have a MapControl within an OverlayControl?

I was curious, because it seems that the magnifier tool presents a MapControl inside an Embedded control or something similar, I could be wrong, could you answer me?

0 Kudos