在固定地图中处理图钉上的水龙头 [英] Handling tap on Pushpin in a fixed Map
问题描述
我有一个显示几个图钉的Map控件.我不希望用户在地图中导航,因此我将其禁用.但是我确实希望用户能够点击图钉(并且在我导航到详细信息页面的情况下).
I have a Map control showing a few Pushpins. I do not want the user to navigate in the map so I disable it. But I do want the user to be able to tap on a Pushpin (and in the event I navigate to a detail page).
但是,当Map.IsEnabled为false时,图钉似乎也不会收到任何手势.我也尝试过使用IsHitTestVisible,但是没有运气.
However when the Map.IsEnabled is false, the Pushpins don't seem to receive any gestures either. I've also tried using IsHitTestVisible, but with no luck.
一些代码显示了我要执行的操作.有人有什么想法吗?
Some code showing what I'm trying to do. Does anyone have any ideas?
<maps:Map Name="Map"
VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
CopyrightVisibility="Collapsed" LogoVisibility="Collapsed" ScaleVisibility="Collapsed" ZoomBarVisibility="Collapsed"
IsEnabled="False">
<maps:MapItemsControl ItemsSource="{Binding TheCollection}">
<maps:MapItemsControl.ItemTemplate>
<DataTemplate>
<maps:Pushpin Name="Pin" Location="{Binding Coordinate}" Content="{Binding Ix}">
<maps:Pushpin.Background>
<SolidColorBrush Color="{StaticResource PhoneAccentColor}"/>
</maps:Pushpin.Background>
<toolkit:GestureService.GestureListener>
<toolkit:GestureListener Tap="PinTap" />
</toolkit:GestureService.GestureListener>
</maps:Pushpin>
</DataTemplate>
</maps:MapItemsControl.ItemTemplate>
</maps:MapItemsControl>
</maps:Map>
推荐答案
将IsEnabled
设置为false
会阻止Map
控件响应用户输入,如您所见,这会影响子Pushpin
.如果您希望地图为只读,但Pushpin
可以响应手势,那么我认为您有两种选择:
Setting IsEnabled
to false
prevents the Map
control from responding to user input, which affects the child Pushpin
as you've seen. If you want the map to be read-only but the Pushpin
to respond to gestures then I think you have two options:
- 处理
Map
控件上的所有手势事件并将e.Handled
设置为true
,这将阻止Map
本身处理该事件,但应保留PushPin
的自由空间来处理轻击手势 - 创建
Map
的WriteableBitmap
并显示,然后在顶部显示Pushpin
(注意:我怀疑Pushpin
控件在Map
控件之外无法正常工作,因此您需要创建/重新模板化控件,使其看起来像Pushpin
).
- Handle all the gesture events on the
Map
control and sete.Handled
totrue
, which will prevent theMap
itself from processing the event, but should leave thePushPin
free to handle the tap gesture. - Create a
WriteableBitmap
of theMap
and show that instead, and then display thePushpin
on top (NOTE: I suspect that thePushpin
control won't work outside of theMap
control, so you'd need to create/re-template a control to look like aPushpin
).
更新:Map
和MapZoom
需要在Map
上进行处理以使其显示为只读"但保持启用状态.
UPDATE: The events that you need to handle on the Map
to make it appear "read-only" but remain enabled are MapPan
and MapZoom
.
这篇关于在固定地图中处理图钉上的水龙头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!