locked
WPF Apps stop responding to touches while mouse continues to work RRS feed

  • Question

  • WPF applications stop responding to the touchscreen (we are using simple button click events) after some period of time (not consistent) but WILL respond to mouse clicks and the non-WPF applications (explorer, etc) continue to respond to touch just fine.

    Because the non-WPF applications respond you can likely rule out the touchscreen drivers.

    Very similar to this post: http://social.msdn.microsoft.com/Forums/vstudio/en-US/0edc6c2c-f869-4e76-b207-5b2d21078a7f/touch-stop-working

    ...except that we are not using a SurfaceWindow nor the 'Surface SDK' and we are using an HP Touchsmart computer.  We are running Windows 7 64 bit using .NET 4.5 (Visual Studio 2012).

    I wonder if Microsoft melded the SurfaceWindow and Window code together at some point?

    Quick Update: We reproduced the issue with our application by disabling the touchscreen in Device Manager and re-enabling it.  WPF application failed to respond to touches afterwards and the rest of the system was still responding to touches.

    And here's a simple MainWindow that you can use in a sample app that will demonstrate the issue:

    public partial class MainWindow
        {
            public MainWindow()
            {
                InitializeComponent();
                this.Topmost = true; //required to display the problem
            }

            private void Button_Click(object sender, RoutedEventArgs e)
            {
                MessageBox.Show("Click!");
            }
        }

      And the XAML:

    <Window x:Class="TestTouchscreenApp.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            Title="MainWindow" Height="350" Width="525">
        <Grid>
            <Button Content="Button" HorizontalAlignment="Left" Margin="142,62,0,0" VerticalAlignment="Top" Width="178" Height="88" Click="Button_Click"/>

        </Grid>
    </Window>


    • Edited by Warfarin Friday, July 5, 2013 7:40 PM Added Sample
    Friday, July 5, 2013 2:18 PM

All replies

  • Hi Warfarin,

    I am trying to involve people who have more experience on this topic. Please be patient, we will back to give you more information soon when get further process on it.
    Thanks for your understanding!

    Regards,


    Lisa Zhu [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, July 8, 2013 7:36 AM
  • Hi there,

    does your issue just happened by disabling the touchscreen in Device Manager and re-enabling it? Has it ever worked on this device before? or do you have Wacom driver on your device?

    How about test result with winform app?

    Regards,

    Jenny

    Tuesday, July 9, 2013 7:07 AM
  • It works with the device.  Disabling and re-enabling the touch screen was done to simulate the touchscreen falling off the USB chain and popping back on.  There are no Wacom devices on the system.

    I will make a quick winform app to test it and post results when done.


    I have verified that the WinForms application does not lose touchability under this scenario.
    • Edited by Warfarin Tuesday, July 9, 2013 7:22 PM Update
    Tuesday, July 9, 2013 1:51 PM
  •  Hello,

    Based on your scenario,  it may be the WPF app or device related, If you still feel that you need assistance with this issue please open a new incident http://go.microsoft.com/fwlink/p/?LinkId=280218 and an expert will try to help you.

    Regards,

    Jenny

     


    Wednesday, July 31, 2013 5:57 AM
  • Actually, the issue has little to do with hardware and seems to be a bug in WPF.  We have been able to reproduce this issue WITHOUT manipulating the device.  Here are the steps:

    With WPF, create a button, have the button open a modal dialog.  Now when you run the app follow this procedure when touching the button:

    1.) Touch the button with your index finger.

    2.) With the index finger still applied, touch the button with your middle finger.

    3.) Remove your index finger from the button.

    4.) Remove your middle finger from the button.

    When the dialog appears, all touch in a WPF application will no longer work.

    This sort of manipulation with two fingers is easy to accidentally do with certain types of touchscreen.

    Monday, August 19, 2013 7:12 PM
  • Hi,

    I'm facing the same problem. Are there any solutions yet?

    Thanks in advance!

    Monday, December 2, 2013 10:44 AM
  • This issue is still existing under .NET Framework 4.5.1.

    If you have any solutions, please let me know.

    Thanks.

    Wednesday, June 18, 2014 8:29 AM
  • This is absolutely not the answer.
    Wednesday, June 18, 2014 6:05 PM
  • There is a bug deep inside .Net Touch APIs that is described here and has not been addressed as of .Net 4.5.1:

    https://connect.microsoft.com/VisualStudio/feedback/details/903760/wpf-touch-services-are-badly-broken

    Tuesday, July 29, 2014 1:15 PM
  • If you're not using Stylus messages disabling the RealTimeStylus solved the problem for me.

    public static void DisableWPFTabletSupport()
            {
                // Get a collection of the tablet devices for this window.  
                TabletDeviceCollection devices = System.Windows.Input.Tablet.TabletDevices;
    
                if (devices.Count > 0)
                {
                    // Get the Type of InputManager.
                    Type inputManagerType = typeof(System.Windows.Input.InputManager);
    
                    // Call the StylusLogic method on the InputManager.Current instance.
                    object stylusLogic = inputManagerType.InvokeMember("StylusLogic",
                                BindingFlags.GetProperty | BindingFlags.Instance | BindingFlags.NonPublic,
                                null, InputManager.Current, null);
    
                    if (stylusLogic != null)
                    {
                        //  Get the type of the device class.
                        Type devicesType = devices.GetType();
    
                        // Loop until there are no more devices to remove.
                        int count = devices.Count + 1;
    
                        while (devices.Count > 0)
                        {
                            // Remove the first tablet device in the devices collection.
                            devicesType.InvokeMember("HandleTabletRemoved", BindingFlags.InvokeMethod | BindingFlags.Instance | BindingFlags.NonPublic, null, devices, new object[] { (uint)0 });
    
                            count--;
    
                            if (devices.Count != count)
                            {
                                throw new Win32Exception("Unable to remove real-time stylus support.");
                            }
                        }
                    }
                }
            }


    • Proposed as answer by MarkusR13 Sunday, January 6, 2019 12:50 AM
    Wednesday, December 3, 2014 5:33 PM
  • Thank You!  Disabling the RealTimeStylus solved the problem for me too. Thank you for that solution! I have been troubled with this touchscreen problem in WPF for 6 months.
    Wednesday, February 22, 2017 7:27 PM
  • MrE ,

    I see you are responding to this problem in the 2017 time period. I have a current WPF App in which touch will suddenly stop working in my app , mouse and keyboard still work if attached. I cannot reproduce the error. it is totally random, but unfortunately it is happening in production. Is this your experience as well and did invoking HandleTabletRemoved like above fix it.

    Others,

    Is this still a current problem with WPF and touch. Is there a way to reproduce it.

    Thursday, September 14, 2017 4:29 PM
  • I just started running into this issue today with a Surface M3.  If left idle for a certain amount of time (haven't been able to pin it down to a certain range), my WPF application will stop responding to all touch input.  The application is still completely responsive and can be manipulated by mouse, but not touch, until restarted.  Running .NET 4.7.1 (app is compiled against 4.5.2).

    Edit:  I don't have any evidence yet, but I have a feeling this may have something to do with a combination of my MainWindow having a style of None and being maximized.  Going to try to change those conditions to see if it results in a difference, and will let everyone know.
    Tuesday, March 27, 2018 8:57 PM
  • Did you ever figure out what was causing this for you? We are experiencing this issue as well.
    Thursday, July 12, 2018 6:42 PM
  • Thanks for this part of the code

    I did have this problem that OP told and this solved the issue, spended more then 8 hours into this and at the end is a bug from the Framework it self.

    Monday, October 8, 2018 1:11 PM
  • I have this problem on Windows 10 v1067 and .NET 4.7.2 and disabling the RealtimeStyle did not solve it for me.

    When this happens, and I stop receiving touch events, I continue to get mouse events but both mouse down and mouse up events fire at the same time, which is the same time as the mouse up event.

    Monday, December 17, 2018 9:15 PM