WPF touch events

Heiko 1,291 Reputation points
2022-02-07T13:57:12.4+00:00

I have a WPF app. In this app context menus are defined in XAML inside border elements. Unfortunately I don't have a Windows device with touch functionality.

1)
If these elements are operated by touch and the user presses a little longer on one of the border elements, does the context menu open automatically? Or do I have to open the context menu myself depending on the time between the TouchDown event and the TouchUp event?

2)
My app is so far operated by clicking with the mouse on TextBlock and Border elements. These do not have a Click event. Therefore I react on their MouseLeftButtonUp events. If these elements are now operated by touch, do I have to react to touch events or are MouseLeftButtonUp events already triggered automatically?

Developer technologies | Windows Presentation Foundation
Developer technologies | XAML
{count} votes

Accepted answer
  1. Hui Liu-MSFT 48,676 Reputation points Microsoft External Staff
    2022-02-09T09:38:18.007+00:00

    Some touch inputs will trigger mouse events if conditions are met. But it will be hard to figure out these interactions without actual touch device. Said that, the answers are:

    1 Touch press and hold will be translated to right click by the OS. So yes, context menu will open.

    2 No, you need to implement custom click event utilizing touch events.


    If the response is helpful, please click "Accept Answer" and upvote it.
     Note: Please follow the steps in our [documentation][5] to enable e-mail notifications if you want to receive the related email notification for this thread. 

    [5]: https://learn.microsoft.com/en-us/answers/articles/67444/email-notifications.html

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.