I have 2 pushpins, pin1 and pin2. How do I change the default black image to my own image? Please help. Thanks
You could use a Image
and add it to a MapLayer
if you don't necesserily need all pushpin functionality.
Example:
MapLayer mapLayer = new MapLayer();
Image myPushPin = new Image();
myPushPin.Source = new BitmapImage(new Uri("YOUR IMAGE URL",UriKind.Relative));
myPushPin.Width = 32;
myPushPin.Height = 32;
mapLayer.AddChild(myPushPin, <LOCATION_OF_PIN>, PositionOrigin.Center);
bingMap.Children.Add(mapLayer);
If you do need have certain Pushpin functionality, another option is to use the PushPin template:
Pushpin pushpin = new Pushpin();
pushpin.Template = Application.Current.Resources["PushPinTemplate"]
as (ControlTemplate);
Then in your application resources XAML , you can define the template like this:
<ControlTemplate x:Key="PushPinTemplate">
<Grid>
<Rectangle Width="32" Height="32">
<Rectangle.Fill>
<ImageBrush BitmapSource="YOUR IMAGE URL" />
</Rectangle.Fill>
</Rectangle>
</Grid>
</ControlTemplate>
来源:https://stackoverflow.com/questions/14559630/change-image-for-pushpin-wpf