请参考活动窗口在WPF? [英] Refer to active Window in WPF?

查看:315
本文介绍了请参考活动窗口在WPF?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何可以参考我在C#WPF应用程序的活动窗口,使用类似的ActiveFor​​m属性的WinForms?

How can I refer to active Window of WPF application in C#, using something like ActiveForm property in WinForms?

推荐答案

一可能的方法是扫描应用程序打开的窗口的列表并检查哪个其中一人有 IsActive = TRUE

One possible way would be to scan the list of open windows in the application and check which one of them has IsActive = true:

Application.Current.Windows.OfType<Window>().SingleOrDefault(x => x.IsActive);



不知道是否有可能不止一个活动窗口,举个例子,有一个模式对话框显示在这种情况下,对话的所有者和对话本身可能是活性

Not sure if there may be more than one active window if, for example, there's a modal dialog showing, in which case, the owner of the dialog and the dialog itself might be active.

这篇关于请参考活动窗口在WPF?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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