This project has moved. For the latest updates, please go here.

How to set pushpin icon to image

Oct 9, 2015 at 2:12 PM
How do I set a pushpin to a .png image? I need to create custom pushpins using different .png images.

Appreciate any help.
Oct 9, 2015 at 2:50 PM
Pushpin is a ContentControl...
Oct 9, 2015 at 5:01 PM
Thanks. Now, I'm using regular images instead of pushpins. How do I refer to the source address of the images? The following code results in null Source and no images show on the map (I'm reading my variables from Access database):

var img = new Image{
                Source = new BitmapImage(new Uri(@"/images/subbasin32.png", UriKind.RelativeOrAbsolute)),
                Width = 32,
                Height = 32,
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment = VerticalAlignment.Center,
                Name = vName

//Set the map location to place the image at
Location location = new Location() { Latitude = vLat, Longitude = vLon };

MapPanel.SetLocation(img, location);

Again, thanks for your important work.
Oct 9, 2015 at 5:37 PM
Edited Oct 9, 2015 at 6:02 PM
With "Pushpin is a ContentControl" I was trying to tell you that you could use it like any other ContentControl. In your case, put an Image into its Content property.

Anyway, when your subbasin32.png image is a resource (i.e. its Build Action is set to Resource), you would have to use a full Resource File Pack URI to access it from code behind. You have however not told if it actually is a resource, and also not what it exactly means that you "read variables from a database". You probably mean that you read some data from a database, but is that the image data? Hard to tell.

Your Pack URI might look like this:
new Uri("pack://application:,,,/images/subbasin32.png") 
Marked as answer by DamaDeNoche on 10/9/2015 at 10:52 AM
Oct 9, 2015 at 5:52 PM
Oh... Anyway, the Uri format you provided works. It's now loading my images. And yes, the images are actual resource with Build Action = Resource. Thank you so much!