Search code examples
wpftouchscreenmouseleftbuttonup

WPF TouchUp Event Strange behaivor


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


Solution

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