2012-12-13 54 views
1

我把这样的Silverlight的必应地图控制图像:如何检索Silverlight bing地图控件上的UIElement的位置?

MapLayer mapLayer = new MapLayer(); 
this.myMap.Children.Add(mapLayer); 

Image image = new Image(); 
BitmapImage btm = new System.Windows.Media.Imaging.BitmapImage(new Uri("/myAssembly;component/Images/myImage.png", UriKind.Relative)); 
image.Source = btm; 
LocationRect rect = new LocationRect(new Location(10, 12), new Location(55, 55)); 

mapLayer.AddChild(image, rect); 

这是工作的罚款。但是我找不到如何在我的代码中找到其他位置的位置。我尝试:

var loc = MapLayer.GetPosition(image) --> Always returning null !!! 

的maplayer对象没有任何方法让孩子们的位置和我不能mapLayer.ParentMap.TryViewportPointToLocation计算位置,因为图像WidthHeight属性始终是0(为什么?)。

我该怎么做?

回答

0

如果您在添加之前将其保存在某处,则可以检索该位置。在某些地方保留这些变量。

new Location(10, 12), new Location(55, 55) 
相关问题