2012-10-25 71 views
0

如果在創建Image的指定恰好碰到的問題是對準不工作WPF Bing地圖:在WPF兵對齊圖片映射

var element = new Image() 
     { 
      Source = ResourceManager.VesselIcon, 
      Opacity = 0.9, 
      Stretch = System.Windows.Media.Stretch.None, 

      VerticalAlignment = System.Windows.VerticalAlignment.Center, // Is not working 
      HorizontalAlignment = System.Windows.HorizontalAlignment.Center 
     }; 

Fortunatley WPF Bing地圖API都提供「PositionOrigin」結構。因此,人們可以在添加形狀地圖本身指定對齊:

Location location = Helper.SomeLocation(); 
this.mapLayer.AddChild(element, location, PositionOrigin.Center); 

希望這將幫助別人

+1

您應該將解決方案作爲答案發布,然後將該答案標記爲已接受。 – Clemens

回答

0

Fortunatley WPF Bing地圖API都提供「PositionOrigin」結構。因此,可以指定對齊方式,同時添加形狀以映射自身:

Location location = Helper.SomeLocation(); 
this.mapLayer.AddChild(element, location, PositionOrigin.Center);