2

I have canvas with listbox inside it. each child element of listbox sets eventhandler for Click event. On canvas I set eventhandlers for

ManipulationStarted="canvas_ManipulationStarted"       
ManipulationDelta="canvas_ManipulationDelta"
ManipulationCompleted="canvas_ManipulationCompleted"

My code for swiping works perfect accept one thing, it fires Click eventhandler before ManipulationCompleted eventhandler.

But for example listbox in the same time scrolls perfectly and do not fire Click event.

So basically what I need is to handle manipulation events in same way listbox do.

If this condition is true:

private void canvas_ManipulationDelta(object sender, ManipulationDeltaEventArgs e)
{ 
     e.DeltaManipulation.Translation.X > [some value]
     ....
}

I need to disable firing Click event on any child element of canvas, doesn't matter if it is inside listbox or not.

rivasyshyn
  • 141
  • 2
  • 4

1 Answers1

0

Why are you setting click handlers if you don't want them to fire?

Click fires on pointer pressed, so there's no way to tell if the user wanted to Click or to start a manipulation. You'll need to either decide based on the location clicked or a later event if you want to differentiate between "clicks" and swipes.

Instead of Click you can handle the Tap gesture along with the manipulation events. Since Tap fires on the pointer released the manipulation system will fire it if the user tap and releases in one spot and it will trigger the manipulations if the user presses and moves the pointer.

See How to handle manipulation events for Windows Phone 8 for more details.

Rob Caplan - MSFT
  • 21,714
  • 3
  • 32
  • 54
  • 2
    Thanks for your suggestions. But regarding Click - it is fires on release not on press, so it execute related click handler after manipulations performed(to be more accurate right before manipulations finished). Here I'm dealing with "bubble up" term which means events goes from child to parent. what ideally I need is "Tunneling" where events goes in opposite direction but it isn't supported in winphone. So it seams that elements with Click handlers should be disabled in same way in the middle of manipulation event, but I can't figure out how to do this. – rivasyshyn Mar 18 '15 at 09:35
  • @Rob Click fires on pointer released by default, not pointerPressed. Unless you specify a different ClickMode on the button. I have the same issue on Windows 10, I can't seem to replicate the same "don't click while I am swiping" behavior like the listview is successfully achieving. – matfillion Jan 04 '16 at 20:48