Is there any way I can detect a long touch over a TextBlock (or a Label)?
相关问题
- VNC control for WPF application
- WPF Binding from System.Windows.SystemParameters.P
- XAML: Applying styles to nested controls
- How can I add a horizontal line (“goal line”) for
- How to properly change a resource dictionary
It is possible to do that in an awaitable fashion. Create a timer with specific interval. Start it when user tapped and return the method when timer elapsed. If user release the hand, return the method with false flag.
For more information, read this post.
There is an event called
TouchAndHoldGesture
andPreviewTouchHoldGesture
Long touch, or press and hold as I think it's formally named, can be detected through the right click event.
It may be that, if you are using a Surface Window, that the right click event is disabled.
There is a ContactHoldGesture event on all Surface controls that you can use. But, and I say this as the guy responsible for creating this feature during my time at Microsoft, this event is very poorly designed and should not be used. It doesn't tell you when the system has decided that a finger has moved too much to count as a "hold" and it doesn't give you information needed to draw an animation telling the user that a "hold" is underway. Your much better off doing what @Kevin suggested and building your own implementation.
As far as I know there is no built in way so you would have to do something like this
• Capture the start time on the TouchDown event of the control
• Compare this to the release time in the TouchUup event
• If the two are different by X then run your long touch code
There might be a few things you have to code around but that is the basic idea