1
votes

My WPF app functions perfectly, but only when using a mouse. Troubles start when using it on a device with a touch screen..

I have a grid that handles MouseLeftButtonUp and TouchUp events.

Now, I press on the grid, it handles related events, then I press on some other control, that other control catches TouchUp event as expected, then TouchUp event is transformed into MouseLeftButtonUp event, which is also something to expect.

However, the newly fired MouseLeftButtonUp event is fired NOT for the control that I pressed on, but for the above mentioned grid! Why does it behave this way?

Thank you in advance...

1
How do you know the MouseLeftButtonUp event "is fired NOT for the control that I pressed on, but for the above mentioned grid" ?franssu
Because both grid and the control I pressed on have MouseLeftButtonUp handlers. Grid's handler is called, and control's handler is not.user3751451
It is another grid, or button, or just some empty space inside layoutcontrol. It is all the same. Even though I explicitly subscribe for MouseLeftButtonUp, control's handler does not get called, but the grid's one does...user3751451
Are you sure you have set a Background (a transparent one will do), on that grid ? As a side note, I'm surprised a Button as the inner-control allows the event to bubble-up.franssu
Well, I didn't. Actually, it is a devexpress gridcontrol, so maybe background is set by default, need to check..user3751451

1 Answers

0
votes

This is normal behaviour for all RoutedEvents. From the UIElement.MouseLeftButtonUp event page on MSDN:

Although this routed event seems to follow a bubbling route through an element tree, it actually is a direct routed event that is raised and reraised along the element tree by each UIElement.

MSDN provides far more answers and far quicker than Stack Overflow.