で使用.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すると、 が機能しなくなりました! どうして?!マウス ハンドラーがキーボード ショートカットにどのようにリンクされているのか理解できません。truePreviewMouseLeftButtonDownInputBinding