简体   繁体   English

图像中心 - Windows Phone

[英]Center of an Image - Windows Phone

I have a bing map and a pin that is to be pinned on the map. 我有一张bing地图和一个固定在地图上的别针。 This pin is an image different from the default one. 此引脚是与默认图像不同的图像。 I want this image to be pinned on the map, and It does work until here. 我希望这张图片固定在地图上,它确实有用,直到这里。 But it pins at the left-top of the image. 但它位于图像的左上角。 I want it to be pinned thru the center of image. 我希望它通过图像中心固定。 (As if you pin a paper on a pinboard not at the left-top of the paper, just thru the center of paper.) (好像你将纸张钉在纸板的左上方,而不是纸张的中心。)

So how can I set this? 那我怎么设置这个呢? VerticalAlignment works for this or not? VerticalAlignment是否适用于此?

Here is my pin image definitions; 这是我的图像定义;

Image pinimage = new Image();
            pinimage.Source = new BitmapImage(new Uri("/Images/killtarget.png", UriKind.Relative));
            pinimage.Width = 64;
            pinimage.Height = 64;

I use Nokia Map API for Windows Phone 8 and was facing the same issue. 我使用诺基亚地图API for Windows Phone 8,并面临同样的问题。 I don't know if the same solution will apply to Bing Maps as well but try setting PositionOrigin property of the Pin...it has to be set the following way:- 我不知道相同的解决方案是否也适用于Bing地图,但尝试设置Pin的PositionOrigin属性...必须按以下方式设置: -

PositionOrigin="0.5,1"

the two numbers represent alignment horizontally and vertically so 0.5,1 means Horizontally center and Vertically bottom. 两个数字表示水平和垂直对齐,因此0.5,1表示水平中心和垂直底部。

Just a bit of clarity. 只是有点清晰。 Windows Phone 8 uses a Microsoft created map control that pulls in Nokia map data. Windows Phone 8使用Microsoft创建的地图控件来提取诺基亚地图数据。 This is exactly what Bing Maps does. 这正是Bing Maps的功能。 There was a bit of a miss communication when they announced the new API. 当他们宣布新的API时,有一点错过的沟通。

As for centering the image you can try the position origin, or you can use margins with negative x and y values. 至于图像居中,可以尝试位置原点,也可以使用负x和y值的边距。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM