在XAML

时间:2016-11-01 14:36:50

标签: c# wpf xaml bing-maps bing

你好我想用XAML禁用移动和缩放bing map,这是我的代码:

<m:Map x:Name="myMap"
           ScaleVisibility="Hidden"
           CredentialsProvider="..." 
           Mode="AerialWithLabels"
           ZoomLevel="1.5"
           />

但是,我怎么能阻止移动和缩放?

谢谢!

1 个答案:

答案 0 :(得分:0)

您必须使用视图更改事件并覆盖中心/缩放值。例如:

var center = myMap.Center;
var zoom = myMap.ZoomLevel;

myMap.ViewChangeOnFrame += (s, e) =>
{
    if(myMap.ZoomLevel != zoom){
        myMap.ZoomLevel = zoom;
    }

    if (!myMap.Center.Equals(center))
    {
        myMap.Center = center;
    }
};