2012-02-21 38 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(); 
} 
相关问题