4

I have created a program that subscribes to WPF's touch events. Everything has been working as expected over the last few months, but yesterday none of the touch events would fire. I tried creating a new, simple program to test touch events, but it works the same, all of the touch input gets sent as mouse events, even though the cursor changes from the mouse arrow to the touch crosshairs.

I restarted the computer several times and reinstalled the drivers but it did not seem to change anything. I have tried using a different brand of touch screen with different drives which also used to work and am seeing the exact same issue. Using the touch screen's built in test tool, I can see that touch and multitouch are working as I expect and viewing the Pen and Touch section of the System Properties confirms that the computer is recognizing the touch screen.

EDIT: I continued to test the monitor and it appears that multitouch is working in other windows programs like paint. The touch appears to not work only in my applications.

Has anyone else experienced this or have any idea how to re-enable the touch events?

Sarah
  • 328
  • 1
  • 6
  • 15
  • I had similar issues but a reboot fixed it... I hate to ask but did you power down completely? – carny666 Jun 21 '12 at 13:51
  • Did u download some update since last time it's working? – Harry89pl Jun 21 '12 at 13:54
  • I did power it completely off several times, sometimes with the screen unplugged and sometimes leaving it in. Didnt seem to make a difference. – Sarah Jun 21 '12 at 13:58
  • I dont believe there were any updates, no. I also do not think it is an update issue because I have seen this happen on a different computer earlier. I just worked around that issue by using my laptop. – Sarah Jun 21 '12 at 14:00
  • If this is a configuration/driver issue, then it probably belongs on SuperUser.com – Nick Jun 21 '12 at 16:15
  • Thanks, I will try asking there too. – Sarah Jun 21 '12 at 16:27
  • Specifically, which events are you listening to and what version of .NET? I'm using .NET 4.5 RC and regularly hook into TouchDown with no problems. I also use MS Surface SDK 2.0 for touch-optimized controls (some WPF controls are already touch optimized, by the way, but Surface controls tend to have some extra features that improve UX). – erodewald Jun 21 '12 at 21:35
  • I am using the UserControl's TouchDown, TouchMove, TouchUp events in .Net 4.0. I tried adding handlers for the Stylus events, because touch events should be routed through Stylus events before sending as a mouse event, but those were not hit either. – Sarah Jun 22 '12 at 11:31

3 Answers3

1

It does not sound like a driver issue. May be in one of your touch down events you are releasing the TouchCapture. You need to check your code. Search for .ReleaseTouchCapture(e.TouchDevice); and check whether you are using this in the right place.

Olivier Jacot-Descombes
  • 104,806
  • 13
  • 138
  • 188
Mukesh Rawat
  • 2,047
  • 16
  • 30
  • It was nothing in the code because creating a very simple program that changed the color based on recieving a touch or mouse down produced the same issue. I was able to fix it by hosting my WPF window in a WinForms window. Why this enabled the touch I have no idea, but it is working again, which is good enough for now. – Sarah Sep 06 '12 at 12:10
1

A bit late for an answer to this specific question but since I had a similar problem and it took me a while to find a solution here is what I came up with. In WPF the click event on Buttons disables touch input. A simple workaround is this new class:

public class TouchButton : Button
{
    public TouchButton()
    {
        TouchDown += TouchButton_TouchDown;
    }

    private void TouchButton_TouchDown(object sender, System.Windows.Input.TouchEventArgs e)
    {
        RaiseEvent(new RoutedEventArgs(ClickEvent));
    }
}

If you change the buttons in your Xaml to TouchButtons, the click will automatically be triggered by a touch(down). It is pretty straightforward and can easily be adapted to all kinds of situations.

Remco
  • 21
  • 3
  • Unfortunatelly doesn't work for me, the button changes color to blue (indicating that there is interaction), but touch/click event is not raised in my app ;/ – prf Aug 06 '21 at 20:03
0

Somehow, converting the Window to a UserControl and hosting inside a WinForms Window fixed the problem and touch events fire as they did before.

Sarah
  • 328
  • 1
  • 6
  • 15