c# – Keyboard Shortcuts in RibbonWindow



I'm developing an application using WPF and window based on RibbonWindow from RibbonControlsLibrary and I'm having problems with Gesture of "Ctrl+0", only with "Ctrl+NumPad0" I was able to perform the action through the numeric keyboard, but the 0 directly do not. That worked:

            Command="{StaticResource RestaurarZoomHandler}"

But this here, it didn't work:

            Command="{StaticResource RestaurarZoomHandler}"

Would they know what the problem is?


Let's read the KeyBinding documentation itself (Google translation).

With the exception of function keys and numeric keypad keys, a valid KeyGesture must contain exactly one Key and one or more ModifierKeys . Function keys and numeric keypad keys do not require a modifier key in order to be a valid KeyGesture . It is possible to specify an invalid KeyGesture and a KeyBinding with an associated invalid 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 short, we cannot specify modifier keys for a key on the numeric keypad. Please use the NumPad0 key or just use Alt + 0 (the Alt plus the D0 numeric keys).

Source: MSDN


As a bonus, I'll leave this little calculator project in WPF , where it uses the System.Windows.Input numeric keypad to get the keyboard data.

Scroll to Top