Assign Short Cut Key to a button in WPF

Viewed 60704

How to assign short-cut key to a button in WPF?

Googling gave me the answer as to append _ instead of '&' in standard Winforms.

So after I have done as below :

<Button Name="btnHelp" Content="_Help"></Button> 

I did not find 'H' underlined.

That is first issue.

Second issue is that, how to execute that after pressing Alt + H at run-time. Say just to display a message box is sufficient for the example sake.

I am using C#, WPF

Thanks.

5 Answers

The simplest solution I've found is to stick a label inside the button:

<Button Name="btnHelp"><Label>_Help</Label></Button> 
Related