Gopinath
Gopinath

Reputation: 1858

How to assign keyboard shortcuts to WPF Ribbon control?

Is it possible to have keyboard shourtcuts for Application Button in WPF Ribbon control?

Upvotes: 7

Views: 4630

Answers (1)

Benny Jobigan
Benny Jobigan

Reputation: 5304

There are 2 ways:

  1. Use the KeyTip property on each level of your ribbon. For example, you need to assign a KeyTip of "H" on your "Home" tab and then "A" on the "Add" button in that tab. If you don't assign KeyTips to the higher levels, you can't access the lower levels. Also, you can assign keytips to the application menu.

  2. If you are using something like the MVVM pattern and are binding to your custom commands, you can make direct "classic" style keyboard shortcuts by binding an KeyBinding to a command in Window.InputBindings.

<Window.InputBindings>
    <KeyBinding Command="{Binding OpenWindow}"
                CommandParameter="About"
                Gesture="F1"/>
</Window.InputBindings>

Ctrl+F and such also work.

Upvotes: 14

Related Questions