Keyboard shortcuts in Ribbonwindow

Asked

Viewed 85 times

3

Hello,

I’m developing an application using WPF and window based on Ribbonwindow of Ribboncontrolslibrary and I’m having problems with the Gesture of "Ctrl+0", only with the "Ctrl+Numpad0" I was able to perform the action through the numeric keyboard, but the directly 0 did not. That worked:

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

Already this here, it didn’t work:

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

Would you know what the problem is?

1 answer

2


Let’s read her own keybinding documentation (google translation).

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

In short, we cannot specify the modifier keys for a key on the number pad. Please use the key NumPad0 or just use Alt + 0 (the Alt plus the number keys D0).

Source: MSDN

Bonus:

As a bonus, I’ll leave this little project of a calculator on WPF, where the numeric keyboard is used System.Windows.Input to get the keyboard data.

  • Really, I read the documentation without attention and ended up going through it.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.