我經常不得不在我的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. 添加控件及其事件動態
- 6. WPF - 從按鈕事件添加控件
- 7. 添加事件mouseDown和mouseMove到我自己的類
- 8. 將文本塊添加到自定義wpf控件(來自codeplex的piepiece控件)
- 9. 如何將此WPF控件添加到我的WinForm中?
- 10. 將控件添加到樣式wpf
- 11. 將事件添加到用於Windows Phone的自定義控件
- 12. 將觸發器添加到WPF自定義控件中
- 13. 爲什麼Visual Studio將「p:」添加到我的所有控件?
- 14. 如何將Click事件添加到自定義的WPF WindowTitle
- 15. 添加我自己的WPF TriggerAction
- 16. 將事件添加到動態添加的控件
- 17. 將自定義事件添加到ASP控件
- 18. 將點擊事件添加到自定義控件
- 19. 將事件處理程序添加到自定義控件
- 20. 將傳統事件添加到自定義控件
- 21. 爲什麼我無法訪問我自己的用戶控件?
- 22. 爲什麼激活者將自己添加到新項目中?
- 23. 將UIElements添加到自定義控件(WPF)
- 24. WPF將c#代碼添加到自定義控件
- 25. 將屬性添加到自定義WPF控件?
- 26. 無效自己的WPF控件
- 27. 將自定義事件添加到Object3D
- 28. 將事件添加到嵌套在Repeater ASP-C中的控件#
- 29. 將事件添加到Windows窗體中的用戶控件
- 30. 如何將事件添加到Silverlight中的模板控件?
查看http://touch.codeplex.com/中的代碼它向您展示瞭如何添加行爲以支持雙擊等手勢。 – 2012-02-21 11:11:56