在WPF bing地图上对齐图像

时间:2012-10-25 18:10:46

标签: wpf wpf-controls bing-maps

如果在创建图片时指定了对齐,则对齐WPF Bing地图无效:

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 Maps API确实提供了“PositionOrigin”结构。因此,可以在添加形状以指定自身时指定对齐:

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

希望它会帮助某人

1 个答案:

答案 0 :(得分:0)

Fortunatley WPF Bing Maps API确实提供了“PositionOrigin”结构。因此,可以在添加形状以指定自身时指定对齐:

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