[英]Left Click on Bing Maps and WPF doesnt work properly
I'm creating a WPF application that use the Bing Maps.我正在创建一个使用 Bing 地图的 WPF 应用程序。 I put it in a page control that at the same time is called from an iframe control.我把它放在一个页面控件中,同时从 iframe 控件中调用。 At the begining it displayed the Map and I can zoom in and out without a problem.一开始它显示地图,我可以毫无问题地放大和缩小。 The thing is, that when I click the Map with the left button of my mouse what it does is to go down a little bit of the current location and a zoom in is done automatically instead of holding the point where the click was done to do a kind of drag and drop.问题是,当我用鼠标左键单击地图时,它所做的是向下一点当前位置并自动放大,而不是保持单击完成的点一种拖放。 Just like Google Maps does.就像谷歌地图一样。
Here is my XAML code:这是我的 XAML 代码:
<Grid x:Name="LayoutRoot">
<TextBlock Text="News page" FontSize="32" />
<m:Map CredentialsProvider="..."
Center="25.6732109,-100.309201" ZoomLevel="12" Mode="Road"/>
</Grid>
I'm using the following assembly reference: xmlns:m="clr-namespace:Microsoft.Maps.MapControl.WPF;assembly=Microsoft.Maps.MapControl.WPF"我正在使用以下程序集参考: xmlns:m="clr-namespace:Microsoft.Maps.MapControl.WPF;assembly=Microsoft.Maps.MapControl.WPF"
Does any one know how can I fix it?有谁知道我该如何解决?
Regards!问候!
If you use the mouse up or down events on the Map control this will work fine. 如果您在Map控件上使用鼠标向上或向下事件,则可以正常工作。 The map itself doesn't expose a Click event of it's own, but you don't need that if you use the mouse up/down events. 地图本身不会公开其本身的Click事件,但是如果使用鼠标上/下事件,则不需要该事件。
I had the same problem.我有同样的问题。 The solution was to add a MouseDown Event to the map:解决方案是向地图添加一个 MouseDown 事件:
<m:Map
CredentialsProvider="<your Credentials>"
Center="{Binding Center, Mode=TwoWay}"
ZoomLevel="10"
MouseDown="Map_MouseDown">
</m:Map>
In the code behind you can add:在后面的代码中,您可以添加:
private void Map_MouseDown(object sender, MouseButtonEventArgs e)
{
e.Handled = true;
}
This handles the event and no further processing is done.这将处理事件并且不进行进一步处理。 After this moving and draging the Map worked as usual maps do.在移动和拖动地图之后,地图像往常一样工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.