Is it possible to let my c# wpf program know if the user has a touchscreen or not?

KDP picture KDP · Apr 15, 2011 · Viewed 8.6k times · Source

I've got an login application that has a swipe system that people only can use when they have a touchscreen. They can login by swiping their personal pattern swipe code.

Is it possible to check in C# or WPF if the user has a touchscreen? Even when he isn't using touch on it at that time?

Answer

Jason Horrocks picture Jason Horrocks · Jun 15, 2011

Within C# code to find out if a touch screen exists (doesn't check if its a single or multi-touch device though) by the using System.Windows.Input namespace in PresentationCore.

    public bool HasTouchInput()
    {
        foreach (TabletDevice tabletDevice in Tablet.TabletDevices)
        {
            //Only detect if it is a touch Screen not how many touches (i.e. Single touch or Multi-touch)
            if(tabletDevice.Type == TabletDeviceType.Touch)
                return true;
        }

        return false;
    }