实现
非常简单,在App启动时为Window类注册事件即可,直接上代码
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
EventManager.RegisterClassHandler(typeof(Window), Window.PreviewMouseDownEvent, new MouseButtonEventHandler(OnPreviewMouseDown));
base.OnStartup(e);
}
static void OnPreviewMouseDown(object sender, MouseButtonEventArgs e)
{
//TODO
}
}
同样地可以用于其他事件的注册
Comments