- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 GreatMaps.NET 库 (https://greatmaps.codeplex.com/) 的面向 MVVM 的分支,但我的问题归结为使用自定义 Canvas 作为 ItemsControl 的 ItemsPanel 的基本问题。本质上, map 是一个 ItemsControl,其中一个 MapCanvas 将其子项放置如下:
protected override Size ArrangeOverride(Size arrangeSize)
{
foreach (UIElement child in Children)
{
PointLatLng position = new PointLatLng(GetTop(child), GetLeft(child));
GMapControl map = Owner as GMapControl;
if (map != null)
{
GPoint p = map.FromLatLngToLocal(position);
p.Offset(-(long)(map.MapTranslateTransform.X + child.DesiredSize.Width * 0.5), -(long)(map.MapTranslateTransform.Y + child.DesiredSize.Height * 0.5));
Rect rect = new Rect(p.X, p.Y, child.DesiredSize.Width, child.DesiredSize.Height);
child.Arrange(rect);
}
}
return arrangeSize;
}
<Setter Property="Canvas.Left" Value="{Binding Longitude}" />
<Setter Property="Canvas.Top" Value="{Binding Latitude}" />
<Setter Property="Canvas.ZIndex" Value="{Binding ZIndex}" />
<DataTemplate DataType="{x:Type viewModels:RouteViewModel}">
<ItemsControl ItemsSource="{Binding Locations}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<wpf:MapOverlay Name="MapOverlay" Owner="{Binding Path=., RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type wpf:GMapControl}}}"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemContainerStyle>
<Style>
<Setter Property="Canvas.Left" Value="{Binding Longitude}" />
<Setter Property="Canvas.Top" Value="{Binding Latitude}" />
<Setter Property="Canvas.ZIndex" Value="{Binding ZIndex}" />
</Style>
</ItemsControl.ItemContainerStyle>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Ellipse Fill="Blue" Stroke="Black" Width="10" Height="10"></Ellipse>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</DataTemplate>
public double Latitude => Locations.Select(loc => loc.Latitude).FirstOrDefault();
public double Longitude => Locations.Select(loc => loc.Longitude).FirstOrDefault();
最佳答案
实际上不是您问题的答案,但它可能会让您大致了解如何显示路线,即由线条连接的圆圈的集合。
以下示例使用 XAML MapControl库,但很可能基于任何其他具有某种 MapItemsControl
的 map 库来实现(例如 MS Bing map )。
我们的想法是收集 Location
构成您的路线的实例。你会有一个 MapPolyline
并绑定(bind)其Locations
属性到路由点集合。然后放一个MapItemsControl
在它上面绑定(bind)它的ItemsSource
到同一个集合。请注意 ItemTemplate
将路径控件与 EllipseGeometries 一起使用而不是 Ellipses,因为它们以点位置为中心,而 Ellipses 顶部/左侧对齐。
<map:MapPanel>
<map:MapPolyline Locations="{Binding RouteLocations}"
Stroke="DarkBlue" StrokeThickness="3"/>
<map:MapItemsControl ItemsSource="{Binding RouteLocations}">
<map:MapItemsControl.ItemContainerStyle>
<Style TargetType="map:MapItem">
<Setter Property="map:MapPanel.Location" Value="{Binding}"/>
</Style>
</map:MapItemsControl.ItemContainerStyle>
<map:MapItemsControl.ItemTemplate>
<DataTemplate>
<Path Fill="Red">
<Path.Data>
<EllipseGeometry RadiusX="5" RadiusY="5"/>
</Path.Data>
</Path>
</DataTemplate>
</map:MapItemsControl.ItemTemplate>
</map:MapItemsControl>
</map:MapPanel>
Location
s 你可以在两个绑定(bind)中使用绑定(bind)转换器将你的路由点类型转换为
Location
.
关于wpf - 没有在 child 身上调用 ArrangeOverride?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38126113/
Closed. This question needs details or clarity。它当前不接受答案。 想改善这个问题吗?添加详细信息,并通过editing this post阐明问题。 4
我有followwing结构 some text Delete 是否可以使用指针事件禁用 div:除了保持按钮处于事件状态之外没有其他功能? 我试过 div.offline:not(.delete)
Here's my fiddle. 基本上我有一个父 div,需要在它周围有一个框阴影,由于各种原因,这个框阴影必须是一个伪元素。此框阴影会阻止捕获此父 div 的子项上的悬停事件。我该如何解决这个问
Cypress 在 Jenkins 中成功使用。从几周 Cypress 规范文件开始,它将永远挂起。它将卡在不同的规范文件中,这使得调试和查找失败的原因变得困难。有时它会成功运行所有规范文件。请帮帮我
我可能遇到了 DOM 和 jQuery 的问题。 我有这个 HTML 结构: 140,86
我有 View Controller A 和 View Controller B。A 具有 B 的序列。A 嵌入在导航 Controller 中。 导航栏在 A 上显示正常,但是在 B 上没有显示。我
试图解决一个有趣的 CSS 问题。 我正在尝试呈现一个最终必须位于相对父级(容器)内部的模态。我需要它是一个固定的叠加层,以便它覆盖整个视口(viewport)。下面包含的代码片段是为了简洁起见。 .
如何让一个自由落体的 Sprite 节点坐在另一个水平移动的 Sprite 体上? 现在两个 body 都发生了碰撞。但是水平运动的物体偏离了它的路径,自由落体撞击水平物体后下降。如何修复 Sprit
我想知道是否可以像这样对第 n 个 child 使用悬停 #gallery a img:hover { display: block; height:300px; width:
这个问题在这里已经有了答案: Why don't flex items shrink past content size? (5 个答案) 关闭 3 年前。 我有一个带有 flex: 1 的 fle
这个问题在这里已经有了答案: How to style the parent element when hovering a child element? (8 个答案) 关闭 9 年前。 所以我有
这个问题在这里已经有了答案: How to style the parent element when hovering a child element? (8 个答案) 关闭 9 年前。 所以我有
所以我的处境有点棘手。基本上我有这个可滚动的水平导航,它有一个 overflow-x: auto。导航具有与悬停时出现的下拉菜单的链接。 溢出会阻止下拉列表在未将其位置设置为 absolute 的情况
在 css 中有什么方法可以只选择悬停的容器子而不需要父级,这可以用 css 实现吗? 这就是我正在尝试的,应该选择最深的容器而不是我添加的 .decor 只是为了显示所选的 div。(这些 chil
有这个 parent : class BaseModel extends Eloquent { protected static $rules = []; public static
我有一个用作编辑器 View 的自定义窗口类,并且由于我直接处理键盘事件,所以我希望在顶部有一个标准的编辑控件来输入文本。我的问题很简单:我也想在用户点击自定义窗口类时获取焦点,所以我处理 WM_MO
我是一名优秀的程序员,十分优秀!