使用. .NET 4.5.1
_ Windows 8.1 Pro
在我的UserControl
我有网格。我需要在这个网格中预览和处理鼠标事件。所以我覆盖了这个PreviewMouseLeftButtonDown
事件:
myGrid.PreviewMouseLeftButtonDown +=
new MouseButtonEventHandler(myGrid_PreviewLeftButtonDown);
}
private void myGrid_PreviewLeftButtonDown(object sender, MouseButtonEventArgs e)
{
// ...
e.Handled = true; // <-- IMPORTANT!
}
我UserControl
也有一些InputBindings
正在静态构造函数中注册。例如:
CommandManager.RegisterClassInputBinding(typeof(MyUserControl),
new KeyBinding(MyCommands.SelectAll, new KeyGesture(Key.A, ModifierKeys.Control)));
InputBinding
依赖PreviewMouseLeftButtonDown
?!
现在,当我在我的处理程序中设置时,我e.Handled
的s 停止工作!为什么?!我无法理解鼠标处理程序如何链接到我的键盘快捷键!true
PreviewMouseLeftButtonDown
InputBinding