2012-02-21 39 views
2

我經常不得不在我的WPF項目中使用TouchDown/TouchUp事件來檢測'雙擊';有時在列表框上,有時是按鈕,有時是一個telerik控件。我將如何去添加一個DoubleTap事件和事件處理程序到這些控件?太大的工作?將我自己的事件添加到WPF控件中涉及什麼?

+0

查看http://touch.codeplex.com/中的代碼它向您展示瞭如何添加行爲以支持雙擊等手勢。 – 2012-02-21 11:11:56

回答

1

您可以創建一個由控件和委託函數引用構造的類。

public class DoubleTap { 
    delegate void ActionFunction(); 
    Control ReferencedControl; 
    public DoubleTap (ref Control referencedControl , delegate actionFunction) { 
     ActionFunction = actionFunction; 
     ReferencedControl = referencedControl; 
     // apply TouchDown and TouchUp event handlers to ReferencedControl 
    } 
    // Put your TouchDown and TouchUp functions for testing the double tap here 
    // when double tap tests as true then call ActionFunction(); 
} 
相關問題