1

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

  • How do you know the MouseLeftButtonUp event _"is fired NOT for the control that I pressed on, but for the above mentioned grid"_ ? – franssu Jun 18 '14 at 08:27
  • 1
    Because both grid and the control I pressed on have MouseLeftButtonUp handlers. Grid's handler is called, and control's handler is not. – user3751451 Jun 18 '14 at 08:32
  • 1
    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 Jun 18 '14 at 08:43
  • 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 Jun 18 '14 at 08:48
  • 1
    Well, I didn't. Actually, it is a devexpress gridcontrol, so maybe background is set by default, need to check.. – user3751451 Jun 18 '14 at 08:51
  • That wouldn't explain why it works with the mouse and not with the touch though.. – franssu Jun 18 '14 at 08:51

1 Answers1

0

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.

Sheridan
  • 68,826
  • 24
  • 143
  • 183
  • 1
    Thank you.. My level of wpf knowlegde is not enough to parse MSDN on my own.. Maybe you could suggest me what I should do to make MouseLeftButtonUp event fire only for the control I pressed on, and not for the others.. – user3751451 Jun 18 '14 at 08:45