1
A
回答
2
使用Mouse.GotMouseCapture附加事件。
public partial class MainWindow : Window {
public MainWindow() {
InitializeComponent();
}
static MainWindow() {
EventManager.RegisterClassHandler(typeof(UIElement), Mouse.GotMouseCaptureEvent, new MouseEventHandler(MainWindow_GotMouseCapture));
}
static void MainWindow_GotMouseCapture(object sender, MouseEventArgs e) {
// e.OriginalSource is a captured element
}
}
請注意,捕獲的元素通過Mouse.Captured static屬性可用。
相關問題
- 1. 當用戶點擊鼠標然後拖動鼠標時,是否有一種乾淨的方式可以捕獲?
- 2. 找出是否有一種方法可以調用另一個方法
- 3. 有沒有一種方法可以區分JavaScript中的鼠標?
- 4. 是否可以將控件錨定到另一個控件?
- 5. 是否有可能在wxFrame中捕獲鼠標事件
- 6. 有沒有一種方法,以確定是否一個方法是要在C#中被內聯
- 7. ejabberd:有沒有一種方法可以確定用戶是否是管理員?
- 8. WPF - 確定是否鼠標在的UIElement
- 9. 在Flex中,是否有一種方法可以捕獲並可選地取消DataGrid中的行選擇事件?
- 10. 確定鼠標是否在控件上? (在一個控制像素範圍內)
- 11. 是否有可能在一種方法中獲得鎖並從另一種方法中釋放它?
- 12. 有一種方法可以捕獲ios中的推送通知?
- 13. WPF是否有可能從另一個線程託管控件?
- 14. 這是一種確定一個幾何是否包含在另一箇中的準確方法?
- 15. 有沒有一種方法可以檢查一個函數在另一個函數中是否屬實?
- 16. 給定一個WPF圖像控件,是否可以確定它的HWND?
- 17. 是否可以將控件放入另一個控件中?
- 18. 是否可以通過JavaScript爲Silverlight控件捕獲鼠標事件?
- 19. 是否可以在屏幕上獲得一種顏色的鼠標座標?
- 20. 在手機safari中是否有另外一種方法可以使用onbeforeunload?
- 21. 在Eclipse中有沒有一種方法可以確定什麼是CPU時間?
- 22. 是否有一種方法可以使一個網格的法線一致?
- 23. 你可以做一個方法==另一種方法?
- 24. 是否有可能在另一個.cpp或.h文件中捕獲異常?
- 25. 在Perl中有一種方法可以判斷一個perl進程是否在使用特定的文件
- 26. HTML:有什麼方法可以確定一個元素是否在另一個元素之後?
- 27. 是否只有一種方法可以在java調用request.getSession()中獲取會話?
- 28. 有沒有一種方法來確定是否刪除用戶?
- 29. 是否可以確定一個對象是否被另一個對象引用?
- 30. 有沒有一種方法可以爲{{render}}指定控制器?
非常感謝您的回答。雖然我還不確定我是否可以使用它。想要知道鼠標是否被捕獲的控件在可視化樹中深處,並且無法在如此高的級別註冊事件處理程序。 –
我明白你的意思,你根本沒有使用MainWindow來註冊事件。所以也許這是我需要的答案,我會再看一遍。 –
有什麼辦法可以取消註冊類處理程序? –