在固定地图中处理图钉上的水龙头 [英] Handling tap on Pushpin in a fixed Map

查看:53
本文介绍了在固定地图中处理图钉上的水龙头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个显示几个图钉的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:

  1. 处理Map控件上的所有手势事件并将e.Handled设置为true,这将阻止Map本身处理该事件,但应保留PushPin的自由空间来处理轻击手势
  2. 创建MapWriteableBitmap并显示,然后在顶部显示Pushpin(注意:我怀疑Pushpin控件在Map控件之外无法正常工作,因此您需要创建/重新模板化控件,使其看起来像Pushpin).
  1. Handle all the gesture events on the Map control and set e.Handled to true, which will prevent the Map itself from processing the event, but should leave the PushPin free to handle the tap gesture.
  2. Create a WriteableBitmap of the Map and show that instead, and then display the Pushpin on top (NOTE: I suspect that the Pushpin control won't work outside of the Map control, so you'd need to create/re-template a control to look like a Pushpin).

更新:MapMapZoom需要在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆