CommandBinding Ctrl + spacebar
-
05-07-2019 - |
문제
Routeduicommand를 구현하는 RoutedCommand 클래스 내부의 명령을 처리합니다. 이렇게하면 CanExecute를 확인하고 필요한 경우 실행하여 명령을 차단하거나 무시하는 데 도움이됩니다. EditingCommand, ApplicationCommand 등을 무시할 수 있습니다. 처리 할 수없는 명령 중 하나는 CTR + SpaceBar입니다. 내가 찾을 수없는 미디어 명령입니까 아니면 다른 유형입니까? 나는 그것이 다른 곳에서 처리되었다고 생각합니다. 그래서 제가 통제 할 수없는 이유입니다.
해결책
자신만의 사용자 정의 명령을 만들거나 사전 정의 된 명령에 새 제스처를 추가 할 수 있습니다.
public Window1()
{
InitializeComponent();
ApplicationCommands.Find.InputGestures.Add(new KeyGesture(Key.Space, ModifierKeys.Control));
CommandBinding commandBinding = new CommandBinding(ApplicationCommands.Find, myCommandHandler);
this.CommandBindings.Add(commandBinding);
}
private void myCommandHandler(object sender, ExecutedRoutedEventArgs args)
{
MessageBox.Show("Command invoked!");
}
다른 팁
WPF 명령을 사용한 경험은 많지 않지만 CTRL 및 SpaceBar에 대한 고유 한 사용자 정의 명령을 작성해보십시오.
이 자습서를 참조하십시오 : http://www.switchonthecode.com/tutorials/wpf-tutorial-command-bindings 및 custom-commands
제휴하지 않습니다 StackOverflow