Introduction
In this article, we will discuss how to add a Pushpin in our Bing Maps and how we can change the image of the Pushpin Icon.
Step 1: First we should add the following references into our program.
using Microsoft.Phone.Controls.Maps;
using System.Device.Location;
Step2: After that in the .xaml page we add this line in the <phone:PhoneApplicationPage> tag.
<phone:PhoneApplicationPage
x:Class="WindowsPhoneApplication9.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
shell:SystemTray.IsVisible="True"
xmlns:my="clr-namespace:Microsoft.Phone.Controls.Maps;assembly=Microsoft.Phone.Controls.Maps">
It is used to declare the map.
Step 3: Now we add a Map with two Buttons (one is used to add the pin in the center of the map and the second is used to change the image of the pin).
<my:Map Height="427" HorizontalAlignment="Left" Margin="12,6,0,0" Name="map1" VerticalAlignment="Top" Width="438" />
<Button Content="Add Center Pushpin" Height="72" HorizontalAlignment="Left" Margin="0,467,0,0" Name="button1" VerticalAlignment="Top" Width="307" Click="button1_Click" />
<Button Content="Chage Pushpin Image" Height="72" HorizontalAlignment="Left" Margin="68,529,0,0" Name="button2" VerticalAlignment="Top" Width="302" Click="button2_Click" />
The Complete Grid Coding is:
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!--TitlePanel contains the name of the application and page title-->




Manoj TarkarPosted May 3, 2012, 2:14 AM
Nice!!!