如何检测不听的框架控制定义的任何鼠标事件鼠标点击? [英] How to detect mouse clicks without listening to any mouse events defined in framework controls?
本文介绍了如何检测不听的框架控制定义的任何鼠标事件鼠标点击?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有可能检测到鼠标点击不听的框架控制定义的任何鼠标事件
Is it possible to detect mouse clicks without listening to any mouse events defined in framework controls?
我的意思是,我不想写这样的代码:<? / p>
I mean, I don't want to write code like :
control.MouseLeftButtonDown += this.HandleMouseLeftButtonDown;
不过,我想知道,如果在屏幕上或没有用户点击。是否有可能在C#(WPF或Silverlight)?
Yet I want to know if user clicks on the screen or not. Is it possible in C# (WPF or Silverlight)?
推荐答案
您可以在静态构造函数注册类处理您的主窗口例如:
You can register a class handler in a static constructor you your main window, for example:
static MainWindow() {
EventManager.RegisterClassHandler(typeof (MainWindow),
Mouse.MouseDownEvent,
new MouseButtonEventHandler(OnGlobaMouseDown));
}
这将成为所有MouseDown事件中,一个全球性的处理程序。
It will be a global handler for all MouseDown events.
这篇关于如何检测不听的框架控制定义的任何鼠标事件鼠标点击?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文