2016-07-26 39 views
0

I ArcGIS Windows-Runtime Esri Projekt und meine XAML ist wie folgt:einige Steuerelemente wie Textblock als ItemSource in C# -Code behind

<esri:MapView x:Name="MyMapView"> 

<esri:MapView.Overlays> 
    <esri:OverlayItemsControl> 
      <Grid MaxWidth="350"> 
       <TextBlock Text="Details" FontWeight="Bold" Margin="0,0,0,4" /> 
      </Grid> 
     </Border> 
    </esri:OverlayItemsControl> 
</esri:MapView.Overlays> 

</esri:MapView> 

Ich will hinter diesen Overlays und OverlayItemsControl in Code hinzufügen, anstatt von XAML .

Ich habe somethig wie dies in C# -Code hinter versucht:

MapView mapView = new MapView(); 
mapView.Overlays.ItemsSource = new List<object> { new TextBlock() { Text = "Details", Name = "overLay" } }; 
mapView.Overlays.Items.Clear(); 
mapView.Overlays.Items.Add(MyMapView.Overlays.ItemsSource); 

Aber es gibt Fehler. Ich weiß nicht genau, was hier falsch ist.

Wie diese Steuerelemente Overlays, Grid, Textblock von Code hinter in diesem Esri MapView?

Antwort

0

Ich bin ein Textfeld an bestimmten Kartenpunkt (mp) durch den Code Zeichnung:

TextBox tbMsg = new TextBox(); 
tbMsg.Width = 250; 
tbMsg.Height = 200; 
tbMsg.Text = "Your Message"; 

tbMsg.GotFocus += Tb_GotFocus; 
tbMsg.Visibility = Visibility.Visible; 


Esri.ArcGISRuntime.Controls.MapView.SetViewOverlayAnchor(tbMsg, mp); 
MyMapView.Overlays.Items.Add(tbMsg); 
+0

Wo ist die Frage. – Gammer

+0

Sie können nicht direkt über das Esri-Kartensteuerelement hinzufügen. –