Help on using short cut keys
I have a WPF user control where I have multiple text boxes and and combo bo开发者_如何学Pythonxes. For easy use I want to provide shortcut keys to focus some main control.
Suppose if I press ALT + M it will focus on a text box named txtPatient
.
txtRef
.
I am using MVVM as the design pattern.
How can I do this?
Sounds to me like basic accessibility (mnemonics), which is easy to obtain by adding labels to your controls like:
<Label Content="_Name" Target="{Binding ElementName=textBoxName}" />
<TextBox x:Name="textBoxName" />
Notice the "_N" - that means when the user presses ALT + N, textBoxName
will get focus.
Thomas Levesque answered this is a separate post here.
He mentions his own custom markup extension which allows for just this:
<UserControl.InputBindings>
<KeyBinding Modifiers="Control" Key="E" Command="{input:CommandBinding EditCommand}"/>
</UserControl.InputBindings>
Hope this helps :)
精彩评论