現在、WPF InputBindings の操作に問題があります。アプリケーション レベルのキーボード バインディングを定義しましたが、コントロールのバインディングを に設定して、コントロールのデフォルトの動作を使用したい場所がいくつかありますNotACommand
。
これは機能していないようです (ただし、別のコマンドで制御レベルのバインディングをオーバーライドすることはうまく機能しているようです)。サンプルコードは次のとおりです。
App.xaml.cs
public void OnStartup()
{
var window = Application.Current.MainWindow.
window.InputBindings.Add(new KeyBinding(CommandA, Key.A, Modifiers.Control));
window.InputBindings.Add(new KeyBinding(CommandB, Key.Delete, Modifiers.None));
}
SomeControl.xaml.cs
public void OverrideBindings()
{
// this invokes LocalCommand instead of CommandA
this.InputBindings.Add(new KeyBinding(LocalCommand, Key.A, Modifiers.Control));
// this still invokes CommandB
this.InputBindings.Add(new KeyBinding(ApplicationCommands.NotACommand, Key.Delete, Modifiers.None));
}
ご意見、ご提案はありますか?それとも、これは完全に間違ったアプローチですか?