首页 > 解决方案 > Winforms上的Bing Maps WPF控件,处理点击事件

问题描述

我正在尝试将 Bing 地图集成到现有的 VB.Net winforms 应用程序中。我遵循了 Ricky Brundritts 指南(https://rbrundritt.wordpress.com/2012/01/05/using-bing-maps-in-winforms/)并创建了一个 WPF 用户控件并将其托管在 ElementHost 中。到目前为止一切顺利,地图显示在我的 winform 中,我可以与之交互(拖动、缩放等)。我可以将 PushPins 添加到地图 OK:

Dim Layer As New MapLayer()
MyMapUserControl.Map.Children.Add(Layer)

Dim pin As New Pushpin() With _
    {
        .Location = New Location(0, 0),
        .Background = New System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Magenta),
        .ToolTip = "This is a test tooltip",
        .Content = "X"
    }

AddHandler pin.MouseLeftButtonUp, AddressOf PushPinMouseUp
Layer.Children.Add(pin)

图钉正确显示,但它不会对鼠标单击做出反应,即永远不会调用 PushPinMouseUp 方法。

我错过了什么?

编辑

我发现我可以检测到对 pin 的双击:

AddHandler pin.MouseDoubleClick, AddressOf PushPinMouseDoubleClick

所以至少有一些事件是有效的,但不是 MouseLeftButtonUp。

标签: wpfvb.netwinformsbing-mapspushpin

解决方案


推荐阅读