Adding hotkeys to labels in WPF forms

Earlier today I was chatting with jfo about adding hotkeys to labels and moving focus to a textbox.

<Label Target="{Binding ElementName=textBox1}"
   
Width="Auto" Height="Auto" Name="label1">
    _First name:

</
Label>
<
Label Target="{Binding ElementName=textBox2}"
    Width
="Auto" Height="Auto" Name="label2">
    _Last name:

</
Label>
<
TextBox Width="Auto" Height="Auto" Name="textBox1"></TextBox>
<
TextBox Width="Auto" Height="Auto" Name="textBox2"></TextBox>

Underscores in the label text chooses what character is hot for that label.  Pressing alt will show the character underlined if it is not always in your windows configuration. 

Target="{Binding ElementName=textBox2}"

Tells the label where to move the focus when the hotkey is pressed.

Here is the resulting app:

Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.

3 Responses to Adding hotkeys to labels in WPF forms

  1. ashwini says:

    hi can i set the textBox2 and textbox1 in runtime? If so how shall i do that ?

  2. Unknown says:

    acer btp-58a1 battery
    acer aspire 1360 battery
    acer btp-51b3 battery
    acer btp-68b3 battery
    acer btp-36d1 battery
    acer travelmate 350 battery

    acer travelmate 360 battery
    acer btp-37d1 battery
    acer travelmate 610 battery
    acer btp-63d1 battery
    acer aspire 3020 battery
    acer aspire 5020 battery
    acer squ-401 battery
    acer travelmate 2300 battery
    acer travelmate 4000 battery

    acer lcbtp03003 battery
    acer squ-410 battery
    acer ferrari 4000 battery
    acer squ-519 battery
    acer aspire 3633 battery
    acer travelmate 3200 battery
    acer 3ur18650f-3-qc151 battery
    acer travelmate 3002wtci battery
    acer travelmate 3002wtmi battery

    acer tm4200 battery
    acer travelmate 4200 battery
    acer aspire 3100 battery
    acer batcl32 battery
    acer batcl32l battery
    acer aspire 200 battery
    acer aspire 2020 battery
    acer btp-33a1 battery
    acer btp-35a1 battery

    acer travelmate 200 battery
    acer travelmate 210 battery
    acer btp-34a1 battery
    acer travelmate 520 battery
    acer travelmate 521 battery

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s