SurfaceScrollViewer:接触嵌套的孩子 [英] SurfaceScrollViewer: getting touch on nested children

查看:26
本文介绍了SurfaceScrollViewer:接触嵌套的孩子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码,它是 WPF 4 UserControl 的一部分:

I have the following piece of code, which is part of a WPF 4 UserControl:

<Popup x:Name="CantoPopup" IsOpen="False" PlacementRectangle="50,-100,500,120" 
               AllowsTransparency="True" PopupAnimation="Fade" 
               StaysOpen="True" Width="500" Height="120">
            <Border BorderBrush="#FF120403" BorderThickness="1" CornerRadius="10" Background="#FF9350">
                <s:SurfaceScrollViewer x:Name="IndexScroller" Width="500" Height="120" Margin="10" VerticalScrollBarVisibility="Disabled" HorizontalScrollBarVisibility="Visible">
                    <DockPanel x:Name="InnerIndexPanel" />
                </s:SurfaceScrollViewer>
            </Border>
        </Popup>

DockPanel 然后在代码隐藏中填充一组 TextBlock.基本上,我正在尝试构建一个可滚动的可触摸项目的水平列表.

The DockPanel is then populated in the code-behind with a collection of TextBlocks. Basically, I am trying to build a scrollable horizontal list of touchable items.

现在,我想检测用户触摸了哪个文本块.但是,将 TouchDown 事件处理程序添加到 TextBlocks 或使用 TouchExtensions 处理点击手势都不起作用.有人可以指出我正确的方向吗?

Now, I would like to detect which textblock was touched by the user. However, neither adding a TouchDown event handler to the TextBlocks nor using TouchExtensions to handle tap gestures worked. Can someone please point me in the right direction?

推荐答案

在幕后,Popup 创建了另一个 hwnd 来渲染其内容.这与所有其他 WPF 控件不同.您需要向 Surface SDK 注册此 hwnd,以便它开始向其发送触摸事件.使用它来做到这一点:http:///msdn.microsoft.com/en-us/library/microsoft.surface.presentation.input.touchextensions.enablesurfaceinput.aspx

Under the covers, Popup creates another hwnd to render its content into. This is different from all other WPF controls. You need to register this hwnd with the Surface SDK so it will start sending touch events to it. Use this to do that: http://msdn.microsoft.com/en-us/library/microsoft.surface.presentation.input.touchextensions.enablesurfaceinput.aspx

这篇关于SurfaceScrollViewer:接触嵌套的孩子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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