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

查看:81
本文介绍了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中的代码填充为TextBlocks的集合.基本上,我正在尝试构建可触摸项目的可滚动水平列表.

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.

现在,我想检测用户触摸了哪个文本块.但是,既没有在TextBlocks中添加TouchDown事件处理程序,也没有使用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天全站免登陆