消息框无法重新设置焦点之后 [英] After messagebox cannot set focus back

查看:72
本文介绍了消息框无法重新设置焦点之后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


在wpf中有焦点问题.在keydown事件处理程序中显示消息框后,Textcontrol失去了焦点,无法重新设置焦点.尝试了textControl.Focus()和Keyboard.Focus(textControl),它们都不起作用.
有人知道如何解决吗?

谢谢
Monish K M

Hi,
Having problem with focus in wpf. Textcontrol lost focus after show a messagebox in keydown event handler and cannot set focus back.Tried textControl.Focus() and Keyboard.Focus(textControl), none of them worked.
Anyone knows how to fix it?

Thanks
Monish K M

推荐答案

可以尝试以下几种方法:

http://stackoverflow.com/questions/828155/cursor-focus-on- textbox-in-wpf-c [ ^ ]

但是,看来您可能已经在朝着正确的方向工作. MSDN有两种不同的方法可以将焦点设置到文本框,具体取决于您想要的内容(键盘焦点还是逻辑焦点).他们说要这样做:

http://msdn.microsoft.com/en-us/library/aa969768.aspx [ ^ ]
Here are a few different things to try:

http://stackoverflow.com/questions/828155/cursor-focus-on-textbox-in-wpf-c[^]

However, it looks like you may have already been working in the right direction. MSDN has a couple different ways to set the focus to a textbox, depending on what you want (keyboard focus versus logical focus). Here is what they say to do:

http://msdn.microsoft.com/en-us/library/aa969768.aspx[^]


这篇关于消息框无法重新设置焦点之后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆