2011-04-15 15 views

回答

17

在C#代碼,以找出是否存在觸摸屏(不檢查其單一或多觸摸設備雖然)通過在PresentationCore中使用System.Windows.Input命名空間。

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; 
    } 
+0

爲什麼這不適合我?請看:http://stackoverflow.com/questions/20923853/why-i-cant-detect-touch-screen – qakmak 2014-01-07 15:25:51

+0

這對我的Win8 Surface平板電腦和Win7筆記本電腦(內置觸摸屏)工作。 – 2015-11-19 22:18:57

+2

15人測試了答案,它的工作原理。爲什麼它沒有被標記爲正確答案? – Harry 2016-07-10 12:30:24

0

有非WPF應用程序在Windows XP Tablet PC版IInkTablet2 COM接口或託管包裝Microsoft.Ink.Tablet類。但是,大多數觸摸屏驅動程序都是「鼠標」驅動程序,無法通過這種方式檢測到。

相關問題