Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to assign keyboard shortcuts to WPF Ribbon control?

Tags:

wpf-controls

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

like image 347
Gopinath Avatar asked Apr 13 '10 04:04

Gopinath


1 Answers

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.

like image 93
Benny Jobigan Avatar answered Sep 16 '22 21:09

Benny Jobigan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!