dobokocka
dobokocka

Reputation: 31

How to enable scrolling with stylus in a WPF touchscreen application?

I have controls like scrollviewer, datagrid, combobox etc.. and I can scroll with my finger, mouse wheel, but not with the attached pen. Is there any behavior, or property where I can enable this functionality?

Upvotes: 0

Views: 433

Answers (2)

SlimeNull
SlimeNull

Reputation: 74

I got the final solution, check this issue in dotnet/wpf repo: github.com/dotnet/wpf/issues/5938#issuecomment-2132226488

Thanks also to @dobokocka, who provided ideas. Finally, I used Stylus to simulate Touch, and performed the correct device capture, and finally achieved the correct effect. And in the logic I wrote, the user can set the "movement threshold", which is less than this Movement of the threshold will be ignored. This allows for pen clicks.

Code here: https://github.com/OrgEleCho/EleCho.WpfSuite/blob/master/EleCho.WpfSuite/Utilities/StylusTouchDevice.cs

Upvotes: 0

dobokocka
dobokocka

Reputation: 31

I had to catch the stylus up/down/move events and convert them to touch events as you can see here the same with mouse events: https://archive.codeplex.com/?p=blakenui

Plus I also wanted to press buttons, select texboxes.. so I calculated the distance in pixels between the starting and the end point. This way I can decide whether it is a simple touch or a scolling move and can set the Handled property accordingly.

Upvotes: 0

Related Questions