Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CommandBinding Ctrl + Spacebar

I handle commands inside a RoutedCommand class that implements RoutedUICommand. This would help me to block or override a command by checking their CanExecute and Execute if needed. I can override EditingCommand, ApplicationCommand, etc.. One of the command that I cannot even handle is Ctr + Spacebar. Is it a MediaCommand or some other types that I cannot find? I guess it is been handled somewhere else, and that's why I cannot control it.

like image 827
paradisonoir Avatar asked Jul 24 '26 13:07

paradisonoir


1 Answers

You can create your own custom command or you can simply add new gesture for predefined command, e.g.:

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!");
    }
like image 128
Hun1Ahpu Avatar answered Jul 26 '26 03:07

Hun1Ahpu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!