我有ArcGIS Windows Runtime Esri项目,我的XAML是这样的:
<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>
我想在代码中添加Overlays
和OverlayItemsControl
而不是XAML。
我在C#代码背后试过这样的事情:
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);
但它给出了错误。我不知道到底出了什么问题。
如何从Esri Overlays, Grid, Textblock
内部的代码中添加这些控件MapView
?
答案 0 :(得分:0)
我通过代码在给定的地图点(mp)绘制文本框:
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);