UWP: ScrollViewer eats touch events away from children? - wpf

In a Universal Windows App, I have a ScrollViewer, and inside it, I have a canvas.
The canvas is trying to handle its own TouchMove event but it's never fireed unless the parent ScrollViewer is disabled.
How can I make the ScrollViewer not stop the touch events from being passed to its children?

You can only set it to cover vertical, horizontal or both of the direction of the gesture by set the ManipulationMode. Or else you have to handle all the scrolling manually.

Related

Highlighting control when mouse is over child control

I have a silverlight templated control that changes opacity when you hover it . However when user points cursor to its child control the effect wores off. I want to have the control highlighted also when the user hovers any child control. I've did the same thing in WinForms by overriding the WndProc method. Is there something similar in silverlight ?
Thanks
Sounds to me like you have not used the correct events to detect the hover, I suspect you are using MouseMove. Instead Use MouseEnter and MouseLeave events. An MouseEnter event will occur when the mouse moves over the control. You move the mouse over child controls and you will get no further events. Then when the mouse moves completely out of your control you will get MouseLeave.

Is there an easy way to make anything draggable in Silverlight XAML?

My target is an entire listbox clipped in a canvas, but I guess there should be something that can work for all controls?
How to make a control draggable and even attached x or y constraints?
You would have to cycle thru all the child controls and add handlers to mouse events.
Within those events you control the drag and the bounds.

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. :)

How can I pass a mouse click to a parent control?

In a Silverlight 2 app, I am using Rectangles on a Canvas to draw a representation of data. I would like to have mouse clicks on the Rectangles be passed on to the control that owns the Canvas. I would also like to be able to show a tooltip with a summary of the data when the mouse is over a Rectangle.
So far I've only been able to achieve one item or the other. If I make the Rectangles have their IsHitTestVisible property = false, the tooltips don't work, but the owning control will receive the mouse clicks. If I set it to true, then tooltips do work, but the clicks don't get passed on.
Is there a way to have a Silverlight item be IsHitTestvisible = true, and pass on the mouse clicks?
I'm not sure why the tooltip and mouse left down / up is being linked, In SL3 the mouse left down / up will bubble unless it gets marked as handled by a routine / object. It sounds more like the event is not bubbling thru the parent controls. AFAIK SL2 does the same. (could be wrong on that one)
What is the visual tree from the outer parent to the inner rectangle?
Have Canvas pass a reference of itself to Rectangles when they're constructed. When a rectangle is clicked, call a method on Canvas.
Edit:
If Rectangles and Canvas are library classes, subclass them to add functionality you need.

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.

Resources