将输入解释为选项卡 WPF [英] Interpret enter as tab WPF
本文介绍了将输入解释为选项卡 WPF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在我的整个 WPF 应用程序中将 Enter 键解释为 Tab 键,也就是说,当用户按下 Enter 时,我的应用程序中的任何地方我都想聚焦下一个可聚焦控件,除非聚焦按钮.有没有办法在应用生命周期中做到这一点?谁能举个例子?
非常感谢!
I want to interpret Enter key as Tab key in whole my WPF application, that is, everywhere in my application when user press Enter I want to focus the next focusable control,except when button is focused. Is there any way to do that in application life circle? Can anyone give me an example?
Thanks a lot!
推荐答案
您可以使用我的 EnterKeyTraversal 附加属性 代码(如果您愿意).将其添加到 WPF 窗口上的顶级容器中,其中的所有内容都会将 enter 视为选项卡:
You can use my EnterKeyTraversal attached property code if you like. Add it to the top-level container on a WPF window and everything inside will treat enter as tab:
<StackPanel my:EnterKeyTraversal.IsEnabled="True">
...
</StackPanel>
这篇关于将输入解释为选项卡 WPF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文