我经常不得不在我的 WPF 项目中使用 TouchDown/TouchUp 事件来检测“双击”;有时在列表框上,有时在按钮上,有时在 telerik 控件上。我将如何向这些控件添加 DoubleTap 事件和事件处理程序?任务太大?
最佳答案
您可以创建一个类,该类是使用对控件的引用和委托(delegate)函数构造的。 (请原谅我不完美的语法[如果它不完美],我是凭内存输入的)
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();
}
关于c# - 将我自己的事件添加到 WPF 控件涉及什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9376426/