Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF Scrollviewer on touch screen tablet

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.

like image 921
Sun Avatar asked Jun 25 '13 09:06

Sun


1 Answers

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.

like image 100
Loetn Avatar answered Sep 28 '22 06:09

Loetn