CommandBinding Ctrl + Space

I process commands inside the RoutedCommand class that implements RoutedUICommand. This will help me lock or redefine the command by checking their CanExecute and Execute if necessary. I can override EditingCommand, ApplicationCommand etc. One of the commands that I can't even handle is Ctr + Spacebar. Is this MediaCommand or some other types that I cannot find? I guess this was handled somewhere else, and why I can't control it.

+3
source share
2 answers

You can create your own command or simply add a new gesture for a predefined command, for example:

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!");
    }
+2
source

I have little experience using WPF commands, but try creating your own commands for Ctrl and space.

See this tutorial: http://www.switchonthecode.com/tutorials/wpf-tutorial-command-bindings-and-custom-commands

0
source

Source: https://habr.com/ru/post/1723941/


All Articles