Search code examples
imagewindows-phone-7center

Center of an Image - Windows Phone


I have a bing map and a pin that is to be pinned on the map. 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?

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;

Solution

  • I use Nokia Map API for Windows Phone 8 and was facing the same issue. 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:-

    PositionOrigin="0.5,1"
    

    the two numbers represent alignment horizontally and vertically so 0.5,1 means Horizontally center and Vertically bottom.