我经常不得不在我的WPF项目中使用TouchDown/TouchUp事件来检测'双击';有时在列表框上,有时是按钮,有时是一个telerik控件。我将如何去添加一个DoubleTap事件和事件处理程序到这些控件?太大的工作?将我自己的事件添加到WPF控件中涉及什么?
2
A
回答
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();
}
0
(请原谅我的不完美的语法[如果它是不完美],我从记忆打字),你将不得不使用this.This行为将包括来自System.Windows.Interactivity.Behavior和覆盖创造派生类型OnAttached TouchDown/TouchUp方法。
请参阅WPF Tutorial | Behaviors和Introduction to Attached Behaviors in WPF了解如何实施行为。
相关问题
- 1. 将我自己的事件添加到我自己定制的UIView的Interface Builder菜单中的“发送事件”
- 2. 将我自己的控件添加到工具箱
- 3. 将事件添加到ASP.NET中的自定义控件中
- 4. 添加控件及其事件动态
- 5. 添加事件mouseDown和mouseMove到我自己的类
- 6. 将文本块添加到自定义wpf控件(来自codeplex的piepiece控件)
- 7. 将控件添加到样式wpf
- 8. 将触发器添加到WPF自定义控件中
- 9. 为什么Visual Studio将“p:”添加到我的所有控件?
- 10. 将事件添加到动态添加的控件
- 11. 如何将Click事件添加到自定义的WPF WindowTitle
- 12. 添加我自己的WPF TriggerAction
- 13. 将点击事件添加到自定义控件
- 14. 将传统事件添加到自定义控件
- 15. 将属性添加到自定义WPF控件?
- 16. WPF将c#代码添加到自定义控件
- 17. 将UIElements添加到自定义控件(WPF)
- 18. 如何将事件添加到Silverlight中的模板控件?
- 19. 将事件添加到嵌套在Repeater ASP-C中的控件#
- 20. 将事件添加到Windows窗体中的用户控件
- 21. 将文件添加到项目时会引发什么事件?
- 22. 添加自己的内容到选项卡UI上的事件
- 23. 添加控制面板在我自己的应用程序事件 - >声音
- 24. 将自定义控件添加到DataGridViewCell
- 25. 将自定义控件添加到MoviePlayer
- 26. 将GMP添加到自己的库中
- 27. 我如何处理c#wpf自定义控件中的事件
- 28. 将我自己的软件包添加到FIWARE的Murano软件包仓库
- 29. 如何将hookBackOfficeHeader中的条件添加到我自己的prestashop模块中?
- 30. 为什么不是WPF控件中的所有事件
查看http://touch.codeplex.com/中的代码它向您展示了如何添加行为以支持双击等手势。 – 2012-02-21 11:11:56