Colonel Panic
Colonel Panic

Reputation: 137682

How to specify access key for a menu item?

How to specify an access key for a menu item?

            <ContextMenu>
                <MenuItem Header="Copy" Command="Copy" />

Per http://msdn.microsoft.com/en-us/library/windows/desktop/bb545460.aspx#accessKeys

Edit: I really mean menu access keys, not shortcut keys.

Upvotes: 3

Views: 1921

Answers (2)

Arsen Mkrtchyan
Arsen Mkrtchyan

Reputation: 50752

You need to create KeyBinding that executes the same command

<Window.InputBindings>
    <KeyBinding Command="Copy" Key="F5" />
</Window.InputBindings>

And if you want to show command inside Menu item you can define it like this

<MenuItem Header="_Copy" InputGestureText="F5"/>

BTW, _ symbol makes the symbol near it as access key

Upvotes: 0

Ravindra Bagale
Ravindra Bagale

Reputation: 17665

use _ at the Header,This will create automatically the desired HotKey.

<MenuItem Header="_Copy"  
InputGestureText="Ctrl+F "/>

Upvotes: 6

Related Questions