- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在将堆栈面板添加到 map 控件。如下图
但是之前添加的一些点在我的堆栈面板的顶部。如何设置我的堆栈面板最顶层?
XAML:
<Grid x:Name="gridMain">
<maps:MapControl
x:Name="mapControl"
ZoomInteractionMode="GestureAndControl"
TiltInteractionMode="GestureAndControl"
RotateInteractionMode="GestureAndControl">
<!--ZoomLevel="{x:Bind ViewModel.ZoomLevel, Mode=OneWay}"
Center="{x:Bind ViewModel.Center, Mode=OneWay}"-->
<maps:MapItemsControl x:Name="MapItems">
<maps:MapItemsControl.ItemTemplate>
<DataTemplate>
<Grid Tapped="MagPoint_Tapped" maps:MapControl.NormalizedAnchorPoint="{Binding NormalizedAnchorPoint}" maps:MapControl.Location="{Binding Location}">
<Ellipse Canvas.ZIndex="0" Width="{Binding Mag5}" Height="{Binding Mag5}" Fill="{Binding MagColor}"/>
<!--<TextBlock Text="{Binding Mag}"/>-->
</Grid>
</DataTemplate>
</maps:MapItemsControl.ItemTemplate>
</maps:MapItemsControl>
</maps:MapControl>
</Grid>
并添加面板代码。
StackPanel sp = new StackPanel();
sp.Background = new SolidColorBrush(Colors.White);
sp.CornerRadius = new CornerRadius(15);
sp.BorderBrush = new SolidColorBrush(Colors.LightGray);
sp.BorderThickness = new Thickness(1);
sp.Width = 260;
sp.MinHeight = 180;
sp.Padding = new Thickness(10);
Canvas.SetZIndex(sp, 99999);
mapControl.Children.Add(sp);
Windows.UI.Xaml.Controls.Maps.MapControl.SetLocation(sp, new Geopoint(new BasicGeoposition { Longitude = (double)fi.geometry.coordinates[0], Latitude = (double)fi.geometry.coordinates[1] }));
Windows.UI.Xaml.Controls.Maps.MapControl.SetNormalizedAnchorPoint(sp, new Point(0.5, 1));
最佳答案
您设置 ZIndex
的方法不起作用,因为 StackPanel
和 MapItemsControl
中的项目位于不同的主机中。
借助 Live Visual Tree,您可以了解它们的具体布局方式。
在上面的屏幕截图中,StackPanel
的宿主(即第一个 Canvas
)被放置在后面 MapOverlayPresenter
的主机(即插入 MapItemsControl
的第二个 Canvas
)。因此,为了让 StackPanel
位于它们之上,您需要手动设置 first Canvas
的 ZIndex
> 到 1
。
一旦你理解了这一点,解决方案就变得简单了——
Loaded += (s, e) =>
{
// GetChildByName comes from
// https://github.com/JustinXinLiu/Continuity/blob/0cc3d7556c747a060d40bae089b80eb845da84fa/Continuity/Extensions/UtilExtensions.cs#L44
var layerGrid = mapControl.GetChildByName<Grid>("LayerGrid");
var canvas1 = layerGrid.Children.First();
Canvas.SetZIndex(canvas1, 1);
};
希望这对您有所帮助!
关于c# - 设置 mapcontrol 的 child 最顶层,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45782511/
我有一个奇怪的问题。我想在 map 上显示某个位置。问题是有时一切正常,但有时我会强制关闭并且在 DDMS 中我得到:06-03 18:24:14.171:错误/AndroidRuntime(2228
我有两个 MapActivities,使用用户当前位置的那个效果很好。当我尝试创建第二个使用硬编码纬度/经度的 MapActivity 时,它会在使用 MapController 设置动画或设置缩放时
我正在尝试使用三指手势而不是一个手指来移动 map 。如果我在我的主要 Activity 中执行 scrollBy() 或 setMapCenter(),事情似乎会按预期进行。但是,例如,如果我在 A
我正在将 API 项目从 .net5 升级到 .net6 它以前工作,现在它崩溃 内部异常消息“抛出了‘Unity.Exceptions.InvalidRegistrationException’类型
我创建了一个简单的 UWP 应用程序,没有代码,只有 XAML。 如果我放大到大约美国州级别,应用程序将因未处理的异常而崩溃。 事件查看器应用程序日志显示: Fa
我正在创建一个 mapView Activity ,但由于某种原因此代码不起作用: @Override public void onCreate(Bundle savedInstanceState){
在 WinRt/WP 8.1 MapControl 中,如何区分用户何时通过滑动更改屏幕中心与程序更改? WinRt/WP 8.1 MapControl 有一个 CenterChanged 事件 (
我有一个坐标为 55.790833、49.114444 的 GeoPoint gPt。我将那个东西添加到 map 中并尝试居中。但是我的标记不在 map 的中心(它稍微高一点)。 怎么了? 这是我的代
我需要向 MapControl 添加一些元素,例如: 我通过代码设置矩形的位置: MapControl.SetLocation(r
我一直在 Google 和 SO 上对此进行研究,但我被卡住了,我想我遗漏了一些基本的东西。大多数examples我见过不处理任意 mapWidth 和单个点,只处理 Overlay 的跨度。 我有一
我正在使用 MapBox 显示特定区域的自定义 map 。在 MapBox 中:我的特定区域是黄色的, map 的其余部分是透明的(见下图)。 我想达到的目标:我想在背景图像上放置一个 MapCont
我正在尝试将谷歌地图集成到我的应用程序中,并为其提供源和目的地以放置标记。它从前几天运行正常,完全没有错误。今天突然出现此错误, map 无法正常工作。即使它没有在屏幕上显示谷歌地图,只是空白的白色屏
我正在尝试将谷歌地图集成到我的应用程序中,并为其提供源和目的地以放置标记。它从前几天运行正常,完全没有错误。今天突然出现此错误, map 无法正常工作。即使它没有在屏幕上显示谷歌地图,只是空白的白色屏
好吧,我正在 Android 中开发一个地理定位应用程序。第一次运行时,我们将 map 以当前位置为中心,然后用户可以自由缩放和平移,但我们有一个按钮可以使 map 动画化并使其回到实际位置。 问题是
这里只是一个有趣的查询,有没有一种方法可以在调用以下任一方法时捕获缩放动画序列何时结束: MapController.zoomIn() or MapController.zoomOut(); 我知道它
我想在 Windows 10 应用程序中将图钉添加到 MapControl,但该控件似乎从 Windows 8.1 开始就消失了。 就这么简单: Pushpin locationPushpin = n
我正在将堆栈面板添加到 map 控件。如下图 但是之前添加的一些点在我的堆栈面板的顶部。如何设置我的堆栈面板最顶层? XAML:
我的 MainPage 上有一个 MapControl,其中 ItemsSource 绑定(bind)到一个 ObservableCollection(通过 x:Bind)。当我导航到另一个页面然后再
我正在使用 UWP map 控件 (MapControl) 和基于 this blog post 的墨迹书写创建 Windows 桌面应用程序. 我有基本的工作。可以在 Canvas 上绘制墨迹并将它
我在 UWP 应用程序中使用带有自定义图 block 源的 MapControl(OSM 通过 HttpMapTileDataSource,替换默认的 bing-maps 图 block )。 总而言
我是一名优秀的程序员,十分优秀!