开发者

How to assign keyboard shortcuts to WPF Ribbon control?

开发者 https://www.devze.com 2022-12-27 04:29 出处:网络
Is it possible to have keyboard shourtcuts for Application Button in WPF Ribbo开发者_JAVA百科n control?There are 2 ways:

Is it possible to have keyboard shourtcuts for Application Button in WPF Ribbo开发者_JAVA百科n control?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号