Keyboard Cruelty Gesture "Ctrl + 1" in RichTextBox Doesn't Work

There is a strange difference when binding commands to tags Ctrl+Nin WPF. Some, but not all, of these gestures are ignored, while others are okay. Has anyone else experienced this behavior by accident?

The structure of the XAML window is very simple: command binding, input binding and DockPanel with menus and RichTextBox. After testing, the problem only appears when the input focus is in the RichTextBox.

For the test, a window input binding was defined for all the numeric keys, as shown below. As a result Ctrl+1, Ctrl+2and Ctrl+5have not done anything, and Ctrl+3, 4, 6-9and 0are working properly. Alt+1, Alt+2Also operating normally.

 <Window.InputBindings>
  <KeyBinding Command="me:MainWindow.MyRC" Gesture="CTRL+0" />
  <KeyBinding Command="me:MainWindow.MyRC" Gesture="CTRL+1" />
  ...
  <KeyBinding Command="me:MainWindow.MyRC" Gesture="CTRL+9" />
 </Window.InputBindings>

Problem Cause

, RichTextBox . RTB, . , RTB.

1

RTB - , :

<RichTextBox.InputBindings>
    <KeyBinding Command="me:WindowBindingTest.MyRC1" Gesture="CTRL+1" />
    <KeyBinding Command="me:WindowBindingTest.MyRC2" Gesture="CTRL+2" />
    <KeyBinding Command="me:WindowBindingTest.MyRC5" Gesture="CTRL+5" />
</RichTextBox.InputBindings>

2

commmand " " , RTB - RTB :

<RichTextBox.InputBindings>
    <KeyBinding Command="NotACommand" Gesture="CTRL+1" />
    <KeyBinding Command="NotACommand" Gesture="CTRL+2" />
    <KeyBinding Command="NotACommand" Gesture="CTRL+5" />
</RichTextBox.InputBindings>
+3
1

, RichTextBox Ctrl + 1 ( "ApplySingleSpace" ). , , .

, , InputBinding RichTextBox, Window, , .

+2

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


All Articles