WPF应用程序不稳定​​焦点 [英] Instable focus of WPF apps

查看:300
本文介绍了WPF应用程序不稳定​​焦点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有问题,WPF,那么它总是涉及对焦点管理。 在有些情况下,我的应用程序输了球完全集中,以便其他应用程序获得的焦点和我的应用程序去的背景。出现这种情况主要是,如果一些窗口在我的应用程序将被关闭。 这是WPF的一个已知的问题。别人是否也有类似的问题?

If I have problems with WPF, then it always concerns the Focus-Management. There are cases, my App loses totally focus so that another application gains the focus and my app goes in the background. This happens mainly if some windows in my app will be closed. Is this a known problem of WPF. Does someone else has similar problems?

我已经打开了<一href="http://stackoverflow.com/questions/3144004/wpf-app-loses-completely-focus-on-window-close">another线程到这一点,但没有人可以帮助,也许这是一个有点详细的。因此,这是这里的短版。

I already opened another thread to this, but no one could help, maybe it was a little to detailed. Therefore this here is the short version.

更新

看来我已经找到了一个简单的黑客,可以帮助prevent我描述了<一的行为href="http://stackoverflow.com/questions/3144004/wpf-app-loses-completely-focus-on-window-close">other螺纹。如果你有同样的问题,尝试,如果它可以帮助你。如果你有一个解释,有一个赏金开放......

It seems that I have found a simple hack that helps prevent the behavior I describe in the other thread. If you have the same problem, try if it helps you. If you have an explanation, there is a bounty open for...

在我离开这个职位开了几天,可能是有人有很好的通用性输入到WPF焦点问题。也许我不明白它背后的逻辑,但直到我就明白了,这是国际海事组织真的WPF(IMO什么是真正很棒的产品)的最糟糕的部分。如果我告诉别人与我在WPF有问题,在过去几年,这将是:Focusmgmt,Focusmgmt和多一次Focusmgmt

I leave this post open for a few days, may be someone has a good general input to the WPF-focus problematic. Probably I don't understand the logic behind it, but until I will understand, this is IMO really the worst part of WPF (what IMO is a really fantastic product). If I have to tell someone with what I had problems the last years within WPF, it would be: Focusmgmt, Focusmgmt, and one time more Focusmgmt.

推荐答案

有关失去焦点为整个应用程序一定要告诉他们,然后再设置上的所有窗口的所有者属性。

For losing focus for the entire app make sure you set the Owner property on all windows before you show them.

有关失去焦点在应用程序中,通常这种情况发生时,一些控制,你没有想到过是获得,但没有显示任何东西(例如一些随机的StackPanel或网格用于布局),你必须寻找那些下跌,并添加可调焦=假

For losing focus inside the app, usually this happens when some control you didn't think off is getting but not showing anything (for example some random StackPanel or Grid used for layout), you have to hunt those down and add Focusable="false"

这篇关于WPF应用程序不稳定​​焦点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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