I'm working on a simple map app for windows phone 8. I set multiple pushpins by using windows phone toolkit. I want to show more details info when a pushpin item is tapped. Here is my code.
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<maps:Map Name="MyMap"
CartographicMode="Road" ColorMode="Light"
LandmarksEnabled="True" PedestrianFeaturesEnabled="True">
<toolkit:MapExtensions.Children>
<toolkit:MapItemsControl Name="allDatas">
<toolkit:MapItemsControl.ItemTemplate>
<DataTemplate>
<toolkit:Pushpin GeoCoordinate="{Binding Coordinate}"
Content="{Binding Name}"
Background="Green"
Foreground="Black"
Tap="Pushpin_Tap"/>
</DataTemplate>
</toolkit:MapItemsControl.ItemTemplate>
</toolkit:MapItemsControl>
</toolkit:MapExtensions.Children>
</maps:Map>
</Grid>
void MainPage_Loaded(object sender, RoutedEventArgs e)
{
ObservableCollection<Data> datas = new ObservableCollection<Data>()
{
new Data() { Coordinate = new GeoCoordinate(22.832991,89.539921), Name = "H", Details = "Hospital", Address = "Address of Hospital" },
new Data() { Coordinate = new GeoCoordinate(22.845489,89.539406), Name = "P", Details = "Fire Station", Address = "Address of Fire"},
new Data() { Coordinate = new GeoCoordinate(22.818019,89.54563), Name = "F", Details = "Police Station", Address = "Address of Police"}
};
ObservableCollection<DependencyObject> children = MapExtensions.GetChildren(MyMap);
var obj = children.FirstOrDefault(x => x.GetType() == typeof(MapItemsControl)) as MapItemsControl;
obj.ItemsSource = datas;
}
private void Pushpin_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
Pushpin pushpin = sender as Pushpin;
if (pushpin.Content != null)
{ //Here i want to show details
MessageBox.Show(pushpin.Content.ToString());
}
}