views:

63

answers:

2

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.

A: 

I have not much experience using WPF commands, but try creating your own custom commands for Ctrl and Spacebar.

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

Tony
A: 

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!");
    }
Hun1Ahpu