Click here to Skip to main content
15,920,688 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

could anybody please tell me how to implement shortcut for my button.

for example i have one button wit text "Save" and i should give shortcut as v in save.
if i press Alt v should be highlighted and when i click alt+v the save functionality should be executed.

i googled and got a solution as to use "AcessText"

code is like:

C#
<button id="Save">

<accesstext>Sa_ve</accesstext>

</button>


but the problem is v getting underlined directly in the save button once the form got loaded. v should be highlighted only when i pressed alt key is pressed.

please suggest
Posted
Updated 1-Feb-15 6:04am
v2

1 solution

Hi,

It's the default behaviour. It's an OS defined behaviour. If you want to change it you may look at this same post in stackoverflow: http://stackoverflow.com/questions/8588004/how-to-show-accesskey-without-pressing-alt-in-wpf[^].

You can try some sort of workarounds with PreviewKeyPress on the window, but it's really awkward...
Or you can try to use Commands, but this way you're going to implement the MVVM pattern.

LG
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900