Skip to content

WPF touch function does not work. #7069

Open

Description

@HouZack
  • .NET Core Version: ALL
  • Windows version: Windows 10 Version 21H2
  • Does the bug reproduce also in WPF for .NET Framework 4.8?: Yes

Problem description:
Sometimes, I met a problem that wpf touch function does not work. I have no idea what's wrong with my computer.
I make a screen recording about this bug .
Actual behavior:
I summarize some tests:

  1. All of the wpf touch function is abnormal even if I restart wpf application. (Button click with touch, inkcanvas touch...).
  2. Disable HID-compliant touch screen, then enable it, still does not work.
  3. Change touch device(monitor) and restart application still does not work.
  4. Change another account(B user) and don't sign out (A current user) Windows, B user's wpf touch is normal,
    and switch to (A user) that wpf touch still don't work.
  5. We doubt there are something wrong with Wisp, because I use other app that is not wpf app, it use wisp and also have the similar question.
  6. If I use "EnablePointerSupport", touch will be normal. But there are some reason I cannot use "EnablePointerSupport". I write a easy sample code to reproduce as attach video.
    Expected behavior:
    Touch can work well.
    Minimal repro:
    When this error occurs, it can always be reproduced as long as Windows is not restarted.
20220916_180336_wpf_touch.mp4

Activity

  1. added
    Investigate
    and removed on Sep 19, 2022
  2. lindexi commented on Sep 21, 2022

    @lindexi
    Member

    @HouZack What is your DPI ? Could you change the system DPI to 100%

  3. HouZack commented on Sep 21, 2022

    @HouZack
    Author

    @HouZack What is your DPI ? Could you change the system DPI to 100%

    My DPI is always 100%.

  4. lindexi commented on Sep 21, 2022

    @lindexi
    Member

    @HouZack Do you have two touch screen?

  5. HouZack commented on Sep 21, 2022

    @HouZack
    Author

    @HouZack Do you have two touch screen?

    Yes, even if I use the second touch screen, the touch still doesn't work. Some of the tests I summarized in the third point above.

  6. lindexi commented on Sep 22, 2022

    @lindexi
    Member

    @HouZack The bad news is maybe it is a known issue. See #2054

    Could you add new WindowInteropHelper(this).EnsureHandle(); before you show the window to test? Thank you

  7. HouZack commented on Sep 24, 2022

    @HouZack
    Author

    @HouZack The bad news is maybe it is a known issue. See #2054

    Could you add new WindowInteropHelper(this).EnsureHandle(); before you show the window to test? Thank you
    @lindexi Because I have rebooted computer and need to wait for next time the problem occurs.

  8. HouZack commented on Oct 21, 2022

    @HouZack
    Author

    @HouZack The bad news is maybe it is a known issue. See #2054

    Could you add new WindowInteropHelper(this).EnsureHandle(); before you show the window to test? Thank you

    @lindexi I add new WindowInteropHelper(this).EnsureHandle(); but touch still not work. Thanks.
    image

  9. 13 remaining items

  10. kircsa08 commented on Jan 28, 2023

    @kircsa08

    @kircsa08 You can try the two ways to solve it when you and @HouZack issues are the same.

    1. re-start the touch module: WPF touch function does not work. #7069 (comment)

    2. Enable the Pointer: WPF touch function does not work. #7069 (comment)

    thank you so much, the 2nd workaround has solved my issue !!

  11. added this to the Future milestone on Sep 15, 2023
  12. RVPryimak commented on Sep 21, 2023

    @RVPryimak

    @HouZack I'm guessing the possible reasons are:

    • There is a problem with the touch module of the system

      • Such as the devices
    • Apps are injected with malware

      • You can try to get the module injected by the application by VMMap tool or ProcessExplorer tool
    • The COM conflict

      • Find the CEB1EF24-BB4E-498B-9DF7-12887ED0EB24 in Windows Register

    More test methods:

    • Using WM_Pointer:
            public App()
            {
                AppContext.SetSwitch("Switch.System.Windows.Input.Stylus.EnablePointerSupport", true);
            }

    @lindexi Hi. I had the same issue with touch. After i use following code almost at all devices touch start to work like it's should but I have a new Surface Pro 9 and if i enable this feature on it. Application start to crash with following exception
    System.ArgumentException: '{0}' must be greater than or equal to '{1}'. (Parameter 'maximum')
    Could it be that this feature 'Switch.System.Windows.Input.Stylus.EnablePointerSupport= true' not exists at new devices?

  13. lindexi commented on Sep 21, 2023

    @lindexi
    Member

    @RVPryimak Could you add more exception info?

  14. RVPryimak commented on Sep 21, 2023

    @RVPryimak

    @lindexi Actualy that is all what i receive. Also i find out that MoudleDoubleClick command stop work with touch after i run 'AppContext.SetSwitch("Switch.System.Windows.Input.Stylus.EnablePointerSupport", true);'

  15. RVPryimak commented on Sep 21, 2023

    @RVPryimak

    @lindexi In my case touch stop working well after any dialog is closed. After this Main windows stop react on touch event at least for first 10. Event if I subscribe to TouchDown event its not raise for first 10-15 click
    After ''AppContext.SetSwitch("Switch.System.Windows.Input.Stylus.EnablePointerSupport", true);''
    Events start to raise like it's should but MouseDoubleClick not works and one device throw exception

  16. lindexi commented on Sep 21, 2023

    @lindexi
    Member
  17. RVPryimak commented on Sep 21, 2023

    @RVPryimak

    @lindexi System.ArgumentException: '{0}' must be greater than or equal to '{1}'. (Parameter 'maximum') at System.Windows.Input.StylusPointPropertyInfo..ctor(StylusPointProperty stylusPointProperty, Int32 minimum, Int32 maximum, StylusPointPropertyUnit unit, Single resolution)
    This error i get from your application. The same what i receive in my after i enable ''AppContext.SetSwitch("Switch.System.Windows.Input.Stylus.EnablePointerSupport", true);''

  18. lindexi commented on Sep 21, 2023

    @lindexi
    Member

    @RVPryimak I'm guessing the problem from your touch screen or the system

    And It appears that the HID descriptor is incorrect

  19. RVPryimak commented on Sep 21, 2023

    @RVPryimak

    @lindexi I will try to provide small example with my issue. I will be appreciate if you will have time to look on it

  20. wangtenghong commented on Nov 13, 2023

    @wangtenghong

    @lindexi
    I already using the fix suggestion that you mentioned in this post

    public App()
            {
                AppContext.SetSwitch("Switch.System.Windows.Input.Stylus.EnablePointerSupport", true);
            }
    

    But our co-work company using a new touch panel in ongoing project and using our product for verification but found our software won't react to click/touch/stylus moving. The error message as following and in attachments. I am wondering if you could do help to check them and give some clues to fix this problem.

    10-30-2023 00:56:23 [Exception in LogUnhandledException] exception: System.ArgumentException: '{0}' must be greater than or equal to '{1}'. (Parameter 'maximum')
    at System.Windows.Input.StylusPointPropertyInfo..ctor(StylusPointProperty stylusPointProperty, Int32 minimum, Int32 maximum, StylusPointPropertyUnit unit, Single resolution)
    at System.Windows.Input.StylusPointer.PointerStylusPointPropertyInfoHelper.CreatePropertyInfo(POINTER_DEVICE_PROPERTY prop)
    at System.Windows.Input.StylusPointer.PointerTabletDeviceInfo.TryInitializeSupportedStylusPointProperties()
    at System.Windows.Input.StylusPointer.PointerTabletDeviceInfo.TryInitialize()
    at System.Windows.Input.StylusPointer.PointerTabletDeviceCollection.Refresh()

    HID_01
    HID_02
    HID_03
    part-of-log.txt

  21. lindexi commented on Nov 13, 2023

    @lindexi
    Member

    @wangtenghong The exception as follow says the touch data do not match the HID Descriptors define.

    10-30-2023 00:56:23 [Exception in LogUnhandledException] exception: System.ArgumentException: '{0}' must be greater than or equal to '{1}'. (Parameter 'maximum')
    at System.Windows.Input.StylusPointPropertyInfo..ctor(StylusPointProperty stylusPointProperty, Int32 minimum, Int32 maximum, StylusPointPropertyUnit unit, Single resolution)
    

    Common issues often involve defining the width and height of touch points in the HID descriptor, but the actual reported touch point data only includes X and Y coordinates, without the width and height information. You can use the BusHound tool to capture packets to understand the touch point data reported by your touch device, and check if there are any definition errors. Additionally, it's also possible that the points you output exceed the maximum and minimum value range defined by your descriptor.

  22. lindexi commented on Nov 13, 2023

    @lindexi
    Member

    And from the code of the constructor in StylusPointPropertyInfo, it is evident that there is an error in your data. Your maximum value is less than your minimum value.

    if (maximum < minimum)
    {
    throw new ArgumentException(SR.Stylus_InvalidMax, "maximum");
    }

  23. added a commit that references this issue on Apr 4, 2026
    6c1875c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    🚧 work in progressInvestigate

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions