My pushpins are added to the map in a common way like this:
C#:
private readonly ObservableCollection<PushpinModel> _pushpins = new observableCollection<PushpinModel>();
public ObservableCollection<PushpinModel> Pushpins
{
get{return _pushpins;}
}
XAML:
<my:MapItemsControl ItemsSource="{Binding Pushpins}">
<my:MapItemsControl.ItemTemplate>
<DataTemplate>
<my:Pushpin Style="{StaticResource PushpinStyle}"
MouseLeftButtonUp="Pushpin_MouseLeftButtonUp"
Location="{Binding Location}"
Content="{Binding Num}">
</my:Pushpin>
</DataTemplate>
</my:MapItemsControl.ItemTemplate>
</my:MapItemsControl>
On clicking a pushpin i can get the Pushpin as sender and get Location information.
But i would like to track down to it's PushpinModel object to get other informations associated with the Pushpin, like name, description, urls, etc. How can i do that?
First of all, you should use the
Tapevent, instead ofMouseLeftButtonUp.Secondly, the
senderin the event handler, is thePushpin, and it'sDataContextproperty is your boundPushpinModel, so simply do: