Keyboard Shortcuts in RibbonWindow

3

Hello,

I'm developing an application using WPF and window based on RibbonWindow from RibbonControlsLibrary and I'm having issues with Gesture from "Ctrl + 0", just with the " Ctrl + NumPad0 "I was able to perform the action through the numeric keypad, but the directly 0 did not. This worked:

        <KeyBinding
            Command="{StaticResource RestaurarZoomHandler}"
            Gesture="Ctrl+NumPad0"/>

Already here, it did not work:

        <KeyBinding
            Command="{StaticResource RestaurarZoomHandler}"
            Gesture="Ctrl+0"/>

Would you know what the problem is?

    
asked by anonymous 24.06.2016 / 13:19

1 answer

2

Let's read KeyBinding documentation .

  

With the exception of the function keys and the numeric keypad keys, a valid KeyGesture must contain exactly one Key and one or more ModifierKeys. Function keys and keys on the numeric keypad do not require a modifier key in order to be a valid KeyGesture. You can specify an invalid KeyGesture and a KeyBinding with an associated bad gesture, either through XAML or code. For example, there is no validation that prevents the creation and binding of a KeyGesture that contains only a non-functioning key, or only modifiers but no key. Such KeyBinding will never attempt to invoke its associated command.

In summary, we can not specify the modifier keys for a key on the numeric keypad. Please use the NumPad0 key or just use Alt + 0 (the Alt plus the numeric keys D0 ).

Source: MSDN

Bonus:

As a bonus, I'll leave this small project of a calculator in WPF , where you use the numeric keypad System.Windows.Input to get the keyboard data.

    
24.06.2016 / 14:37