Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Touch Scrolling ScrollViewer in WPF App with RealTimeStylus Disabled

We are working on a WPF 4.5 application that will be run on Windows 8 computers with touchscreen monitors.

We have disabled support for the RealTimeStylus following the directions on the MSDN, since we have some views that need multitouch support through WM_TOUCH.

The problem is that disabling the RealTimeStylus support seems to also disable the user's ability to scroll a ScrollViewer using touch - normally the user can pan around ScrollViewers with their fingers, but if RealTimeStylus support is disabled, it does not seem possible to do this. The ScrollViewer's PanningMode is set to "Both".

Is it possible to combine these things in a WPF application, or are they mutually exclusive?

like image 640
Chris W. Avatar asked Aug 15 '13 14:08

Chris W.


1 Answers

Another option is to add arrow buttons around the content. We've used this to great effect on a touch screen kiosk. It's a bit more work, but could be made into a custom control. The only code I have supports vertical scrolling.

It should be easy enough to add horizontal scrolling as well. In the code below, there are two buttons, called Less and More above and below the scroller.

    double Epsilon = .001;      private void Scroller_ScrollChanged(object sender, ScrollChangedEventArgs e)     {         if ( Scroller.ScrollableHeight > 0 ) {             Less.Visibility = Math.Abs(Scroller.VerticalOffset - 0) > Epsilon ? Visibility.Visible : Visibility.Hidden;             More.Visibility = Scroller.VerticalOffset + Scroller.ViewportHeight < Scroller.ExtentHeight ? Visibility.Visible : Visibility.Hidden;         } else {             Less.Visibility = More.Visibility = Visibility.Hidden;         }          if (Scroller.ExtentHeight / Scroller.ViewportHeight > 2)         {             SearchPanel.Visibility = Visibility.Visible;         }     }      private void Less_Click(object sender, RoutedEventArgs e)     {         Sounds.Click();         Scroller.PageUp();     }      private void More_Click(object sender, RoutedEventArgs e)     {         Sounds.Click();         Scroller.PageDown();     } 
like image 183
B2K Avatar answered Sep 27 '22 22:09

B2K