views:

67

answers:

1

Hello,

I'm implementing a WPF application with a richtextbox for German users. They want to use their "normal" keyboard shortcuts to do some basic formatting: bold, italic, underline.

In English, the shortcuts CTRL+B, CTRL+I, and CTRL+U are working in the Richtextbox.

However the "normal" German shortcuts are CTRL+SHIFT+F (Fett = Bold), CTRL+SHIFT+K (Kursiv = Italic) and CTRL+SHIFT+U (for Underline). When running the WPF (.net 4.0) application on a German Windows machine (Windows 7), the Richttextbox is not reacting to these shortcuts and also the "English" shortcuts are not working. Only CTRL+SHIFT+F is doing something, but does it wrong: it makes the selected text Italic, not Bold.

Any suggestions on how to fix this? Is there a way to define the shortcut mappings explicitly for the RichTextBox? Any other suggestions? Is this a bug?

Kind regards,

Robbie De Sutter

A: 

I think you can disable command binding you don't want to allow with:

    <RichTextBox.CommandBindings>
     <CommandBinding 
       Command="EditingCommands.ToggleBold" 
       CanExecute="BlockTheCommand"/>
   </RichTextBox.CommandBindings>

    protected void BlockTheCommand(object sender,
         CanExecuteRoutedEventArgs e)
    {
         e.CanExecute = false;
         e.Handled = true;
    }

You could then create custom command bindings for what you want to allow using something like what is shown here: http://www.switchonthecode.com/tutorials/wpf-tutorial-command-bindings-and-custom-commands

KrisTrip
That might work, but unfortunately localization is broken in the sense I have to explicitly map the shortcuts for the target language. Although it is a workaround for the problem (as I am targetting German users), this mean I need to change it for another localization, lets say French. Or if a German user actually prefers English Windows, he might be used to the English shortcuts, which wont work then as well...
Robbie