在wpf中指定快捷键 [英] assign shortcut key in wpf
本文介绍了在wpf中指定快捷键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好
请告诉我如何为按钮控件指定快捷键..
例如保存f2,编辑f3等..
谢谢..
解决方案
访问这里.. 。
http://bytes.com/topic/visual-basic/answers/771699-how-provide-shortcut-keys-controls-like-text-box - 按钮 [ ^ ]
或
< a href =http://www.codeproject.com/Articles/442285/Global-Shortcuts-in-WinForms-and-WPF> WinForms和WPF中的全局快捷方式 [ ^ ]
< br $> b $ b或..
为Windows应用程序启用热键(快捷键) [ ^ ]
嗨。如果您正在使用WPF,那么您可以创建操作命令。
现在您可以使用 InputBinding 概念定义您的自定义手势。
请参阅以下:
< 网格 < span class =code-keyword>>
< 菜单 高度 = 23 背景 = LightGray VerticalAlignment = 热门 >
<MenuItem x:名称 = FileMenuItem 标题 = SaveAs >
< MenuItem。 InputBindings >
< KeyBinding 键 = S 修饰符 = Shift + Alt 命令 = ApplicationCommands.SaveAs / > ;
< / MenuItem.InputBindings >
< / MenuItem >
< / Menu >
< / Grid < span class =code-keyword>>
i希望对您有所帮助。
祝你好运
你可以试试这个
在UserCont中编写代码rol_Keydown事件
如果 e.Key = Key.F1 然后
btnNew_Click(发件人,e)
ElseIf e.Key = Key.F2 < span class =code-keyword>然后
btnSave_Click(发件人,e)
ElseIf e.Key = Key.F3 然后
btnFind_Click(发件人,e)
ElseIf e.Key = Key。 F4 然后
btnEdit_Click(发件人,e)
ElseIf e.Key = Key .F5 然后
btnDelete_Click(发件人,e)
ElseIf e.Key = Key.F7 然后
btnCancel_Click(发件人,e)
ElseIf e.Key = Key.E scape 然后
btnExit_Click(发件人,e)
结束 如果跨度>
Hi all
Please tell me how to assign shortcut key to button control..
e.g. for save f2, edit f3 etc..
Thank you..
解决方案
visit here...
http://bytes.com/topic/visual-basic/answers/771699-how-provide-shortcut-keys-controls-like-text-box-button[^]
or
Global Shortcuts in WinForms and WPF[^]
or..
Enabling Hot Keys (Short Cut keys) for windows Application[^]
Hi. if you are working with WPF then you can create command for action.
now you can define your custom gesture by using InputBinding concept.
see following:
<Grid> <Menu Height="23" Background="LightGray" VerticalAlignment="Top"> <MenuItem x:Name="FileMenuItem" Header="SaveAs" > <MenuItem.InputBindings> <KeyBinding Key="S" Modifiers="Shift+Alt" Command="ApplicationCommands.SaveAs"/> </MenuItem.InputBindings> </MenuItem> </Menu> </Grid>
i hope this help you.
good luck
You can try this
Write the code in UserControl_Keydown event
If e.Key = Key.F1 Then btnNew_Click(sender, e) ElseIf e.Key = Key.F2 Then btnSave_Click(sender, e) ElseIf e.Key = Key.F3 Then btnFind_Click(sender, e) ElseIf e.Key = Key.F4 Then btnEdit_Click(sender, e) ElseIf e.Key = Key.F5 Then btnDelete_Click(sender, e) ElseIf e.Key = Key.F7 Then btnCancel_Click(sender, e) ElseIf e.Key = Key.Escape Then btnExit_Click(sender, e) End If
这篇关于在wpf中指定快捷键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文