触摸屏平板电脑上的 WPF 滚动查看器 [英] WPF Scrollviewer on touch screen tablet

查看:80
本文介绍了触摸屏平板电脑上的 WPF 滚动查看器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个 WPF 应用程序,它将在完整的 Windows 8 触摸屏平板电脑(不是 RT)上运行.

I'm writing a WPF application that is going to run on a full windows 8 touchscreen tablet (not RT).

但是触摸滚动似乎不起作用.所以我想知道是我做错了什么,还是有可能?

However touch scrolling doesn't seem to be working. So I'm wondering if it's something I'm doing wrong or if it's even possible?

所以,我有一个带有滚动查看器的 WPF 窗口.在该滚动查看器中,我有一个 StackPanel,其中包含大量文本块.见下文:

So, I have a WPF window with a scrollviewer. Within that scrollviewer I have a StackPanel which has loads of textblocks within it. See below:

<ScrollViewer>
        <StackPanel>
            <TextBlock Text="Row 1" />
            <TextBlock Text="Row 2" />
            <TextBlock Text="Row 3" />
            <TextBlock Text="Row 4" />
            <TextBlock Text="Row 5" />
            <TextBlock Text="Row 6" />
            ....
            <TextBlock Text="Row 50" />                
        </StackPanel>
    </ScrollViewer>

现在使用触摸屏,我尝试滚动内容,但它不动.我只能使用 side scollbar 滚动内容,这不是我想要的工作方式.是否可以使用 WPF 进行触摸滚动?我也想对网格做同样的事情.

Now using the touchscreen I try to scroll the contents but it doesn't move. I can only scroll the contents using side scollbar which is not how I want this to work. Is it possible to get touch scrolling working with WPF? I'd also want to do the same with the grid.

提前致谢.

我使用的是 Visual Studio/Blend 2012.

I'm using Visual Studio/Blend 2012.

推荐答案

您可以使用 PanningMode 属性启用滚动,如下所示:<ScrollViewer PanningMode="Both"></ScrollViewer>.

You can enable scrolling with the PanningMode property like this: <ScrollViewer PanningMode="Both"></ScrollViewer>.

请参阅:MSDN

鼠标支持

如果你想用鼠标实现这个行为,请阅读这篇文章.

If you want to implement this behavior with the mouse, please read this article.

这篇关于触摸屏平板电脑上的 WPF 滚动查看器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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