简体   繁体   English

WPF窗口没有获得焦点

[英]WPF window doesn't get focus

I'm having a problem where my main application window keeps the focus after a non-modal window is initiated from it. 我遇到一个问题,即从该窗口启动非模式窗口后,我的主应用程序窗口保持焦点。 It seems at first glance that it might be the hollow windows issue with WPF (we use transparent backgrounds), but the window doesn't even have focus at all (this.IsFocused STAYS false). 乍看之下,WPF可能是空心窗户问题(我们使用透明背景),但是窗户甚至根本没有焦点(this.IsFocused STAYS为假)。

As soon as you click on the window, the click goes through to the main window behind it. 单击该窗口后,单击将转到其后面的主窗口。 After which, if the window is activated from the windows taskbar, the window has focus, can be activated, and accepts all clicks. 之后,如果从Windows任务栏激活了该窗口,则该窗口具有焦点,可以被激活并接受所有单击。

I've tried taking focus from the window itself, with API calls, trying to simulate the clicks, the whole toot. 我尝试通过API调用从窗口本身获取焦点,尝试模拟点击和整个声音。

What I think might be happening is that somewhere, something else is keeping focus on the main window once the child window is generated (this is NOT an MDI environment). 我认为可能正在发生的事情是,一旦子窗口生成(这不是MDI环境),其他地方就会将焦点集中在主窗口上。 Is there some application that allows me to check which WPF element has focus, or somehow makes it possible for me to trace the focus in the application? 是否有一些应用程序可以让我检查哪个WPF元素具有焦点,或者以某种方式使我可以在应用程序中跟踪焦点? I've tried snoop, and it doesn't play well with our app (makes it fall over). 我已经尝试过监听,但它在我们的应用程序中无法很好地发挥作用(使其崩溃)。

Any other ideas or suggestions would be greatly appreciated. 任何其他想法或建议,将不胜感激。

This may be a known issue with RPC services, it cannot be fixed and it is not your code fault. 这可能是RPC服务的已知问题,无法解决,也不是您的代码错误。 Reboot your system and try again this scenario. 重新启动系统,然后重试此方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM