1

I have a window with 3 textboxes and labels with following properties:

 <Label x:Name="label" Content="_Label" Target="{Binding ElementName=textBox}"/>
 <Label x:Name="label1" Content="Label"/>
 <Label x:Name="label2" Content="_Label" Target="{Binding ElementName=textBox2}"/>

See this image

You can see that "label" and "label2" have the same ALT + L key but different Target property. When I focus textBox middle and I press ALT + L I need that textBox2 is focues (like in MFC). I can't use code behide because I was made about 200 windows. Thanks a lot!

Il Vic
  • 5,576
  • 4
  • 26
  • 37
  • You should avoid duplicate hotkeys as much as possible... Select another letter as the shortcut. If not possible, the try to update other conflicting shortcut. If still not possible, verify if you can change some label (or maybe append a letter in parenthesis at the end like Label1 (_k)). – Phil1970 Oct 24 '16 at 23:04
  • I also think that usually, it would be preferable to have a few controls missing shortcut than having duplicate one. It make the software more predictable... – Phil1970 Oct 24 '16 at 23:09

1 Answers1

0

I think if you really need with out code behind or ViewModel you can do it by adding the same short cut to Label1 like below,

    <Label x:Name="label" Grid.Row="0" Content="_Label" Target="{Binding ElementName=textBox}"/>
    <Label x:Name="label1" Grid.Row="1" Content="_Label" Target="{Binding ElementName=textBox1}"/>
    <Label x:Name="label2" Grid.Row="2" Content="_Label" Target="{Binding ElementName=textBox2}"/>
    <TextBox x:Name="textBox" Grid.Column="1" Grid.Row="0"/>
    <TextBox x:Name="textBox1" Grid.Column="1" Grid.Row="1"/>
    <TextBox x:Name="textBox2" Grid.Column="1" Grid.Row="2"/>

If you can make a ViewModel then InputBinding with KeyBinding can make it work.

Abin
  • 2,868
  • 1
  • 23
  • 59