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

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?

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.

Related

Change number of lines mouse wheel scrolls in WPF ListBox

In a WPF listbox, rotating mouse wheel will scroll list by the number of lines specified in Windows Control Panel, in Mouse Wheel options.
How can I change this, for example I want to scroll WPF ListBox, one line anytime, using mouse wheel.
Thank you.
As you stated it is a control panel setting and you are trying to override it. That will confuse the user. I recommend you to not do that.
However you could try and override various events and position the vertical scrolling by using scrollViewer.ScrollToVerticalOffset(...);
As stated by ygoe in a comment, what you are looking for is :
ScrollViewer.CanContentScroll="False"
In my tests, it does scroll the list one line at a time.
Of course, you should consider that it overrides a global windows setting, as stated by Erno

How can I set the focus for a DevExpress XtraGrid so the mouse wheel works right away?

The UI for my WinForms app is centered around a DevExpress XtraGrid.
Usually, the first thing a user wants to do is scroll the grid, so the normal instinct is to move the mouse wheel.
But currently, you have to click a row in the grid first, which is annoying.
I tried to use BaseView.Focus method, but this did not work - still had to click a row before the wheel would work.
Any suggestions on how to accomplish this?
By default, the Grid is scrolled by mouse wheel only if the mouse pointer is above the grid. So, an attempt to focus it does not help. To change this behavior, you should change the static SmartMouseWheelProcessing property in the form's constructor as shown below:
DevExpress.XtraEditors.Drawing.MouseWheelHelper.SmartMouseWheelProcessing = false;

MouseWheel: Scrolling vs. Zooming

I've got a Silverlight 4 custom control that basically is several Canvas elements wrapped inside a ScrollViewer. The user can set a property to determine whether to scroll or zoom when using their mouses wheel. In the custom control's MouseWheel event, I check to see if they want to scroll or zoom. If zooming, I determine the delta and modify the custom control's zoom level (which then handles the zooming code for me).
The problem is that zooming won't start until the ScrollViewer's current position of the vertical scrollbar is at the top or bottom of the scrollbar. Once their, then the zooming works perfectly.
Does anyone have any suggestions on how I can prevent scrolling completely so that I only zoom (when the user wants to zoom, that is)?
Thanks!
Looks like one of my child elements was hogging the MouseWheel event. I traced this by adding Debug.WriteLine statements to each of the child element's MouseWheel event as well as the parent control's MouseWheel event.
So, I can't blame SL4. Just myself. :)

WPF: How do I allow scrolling with the mouse wheel in a ListView while dragging ListView items?

I have implemented drag and drop in a ListView in my WPF application. Items can be dragged and dropped inside the ListView, and also into a TreeView that is beside the ListView.
Currently, I have it set up so that when you drag to the bottom of the ListView, it automatically scrolls down the list.
What I'd like to know is if there's any way to be able to scroll through the ListView with the mouse wheel while I'm dragging its items? It seems like the mouse wheel events aren't being fired while I'm dragging.
create (and start) mouse hook helper before DragDrop.DoDragDrop(...)
analyze mouse wheel (+ check if mouse over control)
stop (dispose) mouse hook helper after DoDragDrop() operation
Note: always stop mouse hook helper, because it can freeze application when it dispose on Window close (I see it on XP).
here you can find one MouseHook, adopt it (I found bug:)) or something like it.

WPF MouseMove Event Polling

I've created a WPF application where the title bar and chrome are turned off. I have a border around the entire app, with the idea that it would act like the chrome in some regards. The first thing I'm trying to do is have the mousemove event capture the movement of the mouse when the mouse is clicked, so that the window moves with the mouse. The problem is that if the mouse moves too quickly, it manages to leave the window and therefore the mousemove no longer fires. I've been able to do this with a normal WinForm with no problems regardless of the speed of the mouse. Is there any way to do this more efficiently, or perhaps tune the polling of the mousemove? Perhaps a different container other than border that would perform better?
Try Me.DragMove in the window's left click event handler. It much better than most custom solutions.
When the user clicks you should capture the mouse (see Mouse.Capture). That way, you'll get the mouse events regardless of whether the mouse cursor is over your element or not.

Resources