I've inherited an WPF application that targets Net 3.5, And I have to install it in a Surface Pro 4 (I5). The application is hanging in different points, and I have observed that animations sometimes never fire the completed event (maybe they end up at some point, but not at the time expressed in Duration property).
As a turnaround, I tried Disable the RealTimeStylus for WPF Applications but after several trials, I noticed that although the DisableWPFTabletSupport method is executed and finishes (I added log code in DisableWPFTabletSupport method and four devices are removed in the Surface Pro 4), probably WPF Tablet Support is still active in my application, because the application continues hanging from time to time and continues capturing screen touches.
So, the only way I've found to be able to successfully run an WPF application targeting Net 3.5 in Surface 4 Pro is use the Windows Device Manager to disable all touch screen related devices in human interfaces.
Anyone know how I can disable WPF Tablet Support in Surface 4 Pro?
Note. Despite what is said on disable and enable the touchscreen driver, it is not enough to disable "HID-compliant touch screen devices": until the "Intel(R) Precise touch devices" is not disabled, the touch screen remains activated and most WPF applications will fail.
I had the same problem and was able to find a work-around using reflection.
The issue is caused by WPF updating its internal tablet device handling when the window messages WM_TABLET_ADDED, WM_TABLET_REMOVED or WM_DEVICECHANGED are sent (see .net referencesource). As these messages might or might not be generated depending on the hardware used, the original DisableWPFTabletSupport method might be enough or not.
My solution was to handle and hide those three window messages from WPF in addition to the original code:
Some notes on this implementation and limitations:
WPF does not register to these messages on the applications MainWindow, but through a hidden windows named "SystemResources..." which is created for each application instance. So handling those messages on the MainWindow (which would be easy) does not help here.
My solution also uses quite some reflection and calls into internal classes and internal properties. It works for .net 4.6.2 and have not tested it on earlier versions. Moreover, in my deep dive into the .net source code I also saw two other potential paths in which the tablet handling is updated, which are not handled in this solution: The constructors of TabletCollection and of HwndStylusInputProvider.