2
我增加了一些推平到一定到數據源的地圖。獲取當前項目的數據綁定項
<my:Map Height="340" HorizontalAlignment="Left" Margin="12,100,0,0" Name="settingsmap" VerticalAlignment="Top" Width="438" CredentialsProvider="_">
<my:MapItemsControl Name="settingsMapItemControl" MouseLeftButtonDown="settingsMapItemControl_MouseLeftButtonDown">
<my:MapItemsControl.ItemTemplate>
<DataTemplate>
<my:Pushpin Location="{Binding location}">
</my:Pushpin>
</DataTemplate>
</my:MapItemsControl.ItemTemplate>
</my:MapItemsControl>
</my:Map>
推針綁定到dataitem的「位置」成員。
現在,當有人點擊引腳(或觸摸手機)時,我如何獲得綁定到該引腳的項目(從綁定到映射的對象列表中)? 我想基本上獲得該項目,這樣我可以在屏幕底部顯示一個類似名稱等其他信息。或者說像您選擇「XYZ」
(sender as Pushpin).DataContext => null –
是DataContext null還是發件人不是圖釘? – TDaver
因爲如果圖釘沒有DataContext,那麼'{Binding location}'也不應該工作(除非你從代碼隱藏中做了一些事情,並且不告訴我們... – TDaver