Disable mouse promotion

孤者浪人 提交于 2019-12-01 09:25:28
public static class PreventTouchToMousePromotion
{

    public static void Register(FrameworkElement root)
    {
        root.PreviewMouseDown += Evaluate;
        root.PreviewMouseMove += Evaluate;
        root.PreviewMouseUp += Evaluate;
    }

    private static void Evaluate(object sender, MouseEventArgs e)
    {
        if (e.StylusDevice != null)
        {
            e.Handled = true;
        }
    }
}

Excample Usage:

public MainWindow()
    {
        InitializeComponent();
        PreventTouchToMousePromotion.Register(this);
    }

or take a look at this post

http://social.msdn.microsoft.com/Forums/vstudio/en-US/9b05e550-19c0-46a2-b19c-40f40c8bf0ec/prevent-a-wpf-application-to-interpret-touch-events-as-mouse-events?forum=wpf#9965f159-04a4-41ed-b199-30394991f120

There doesn't seem to be any such option (at least up to Windows 8.1 and .NET 4.5).

The only way to disable mouse promotion is to disable finger input completely, either from within the system control panel (open control panel, open "Pen and Touch", select "Touch" tab, disbale "Use your finger as an input device") or via Registry (HKLM\Software\Microsoft\Wisp\Touch, TouchGate = 0 =disable touch)

Then you can still process touch input using one of the following (nasty) alternatives:

Finally, you can inject the collected touch data into your application using custom routed events or using touch injection.

In any case you will, of course, loose touch support for any other application on your system, so this solution will in general not be too helpfull to you.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!