Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF ScrollViewer scroll sensitivity

I am developing a WPF application for use on a point of sale with a touch screen. I have an ItemsControl with product buttons inside a ScrollViewer. The user can scroll (pan) through the products by dragging with their finger. To add a product to the shopping cart, the user simply touches the product button. So far so good.

However, since the touch screen surface is quite smooth and polished, the users's finger sometimes slips a tiny bit when trying to press a button. In that case, the button click is not registered. Instead, the ScrollViewer scrolls for that tiny bit of movement.

Now, my question is: is there a way to reduce the sensitivity of the ScrollViewer, so that it would take a longer drag to initiate scrolling and suppressing the click event.

Thank you for any advice!

Best regards,

Chris

like image 411
Christophe Avatar asked Jul 22 '26 11:07

Christophe


1 Answers

I had same sensitivity problem, and solved it this way:

Created own ScrollViewer, which inherits from native ScrollViewer:

  1. Override OnManipulationDelta method
  2. Check that finger has moved enough (e.CumulativeManipulation.Translation.Y)
  3. If not, do not call base.OnManipulationDelta(e). Otherwise, call base.OnManipulationDelta(e)

It seems that native control panning treshold is little as 3 pixels and this is why touch click is registered easily as panning. By this trick, you can define your own treshold. I used 35pixels (to be exact, device independent pixels in WPF)

like image 69
Mika Avatar answered Jul 26 '26 11:07

Mika



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!