WPF Scrollviewer on touch screen tablet

天涯浪子 提交于 2019-12-10 02:39:59

问题


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?

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>

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.

Thanks in advance.

I'm using Visual Studio/Blend 2012.


回答1:


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

See: MSDN

Mouse support

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



来源:https://stackoverflow.com/questions/17294135/wpf-scrollviewer-on-touch-screen-tablet

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!