Application.OpenForms 的 WPF 版本
我有一个应用程序,我必须在其中打开另一个打开的 WPF 窗口。在 WinForms 中,我能够使用:
MainWindow main = (MainWindow)Application.OpenForms["MainWindow"];
能够访问表单。现在在 WPF 中它不存在。我已经在该网站上看到了其他相关的帖子,但是它使用未包含在调用中的 Application.Window 。我只有:
- Current
- Equals
- GetContentStream
- GetCookie
- GetRemoteStream
- GetResourceStream
- LoadComponet
- RefrenceEquals
- ResourceAssembly
- SetCookie
所以我的问题是,OpenForms 是否有不同的版本,或者是否有不同的方法来解决它。
I have an application in which I will have to get at another WPF window which is open. In WinForms, I was able to use:
MainWindow main = (MainWindow)Application.OpenForms["MainWindow"];
To be able to access the the form. Now in WPF it does not exist. I have seen the other post on this site which is relevant, however it uses Application.Window which is not contained in the call. I just have :
- Current
- Equals
- GetContentStream
- GetCookie
- GetRemoteStream
- GetResourceStream
- LoadComponet
- RefrenceEquals
- ResourceAssembly
- SetCookie
So my question is this, is there a different version for OpenForms, or is there just a different way to go about it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尝试查看:
Application.Current
。更具体地说,Application.Current.Windows
。Try looking at:
Application.Current
. More specifically,Application.Current.Windows
.我可能会迟到,但以防万一有人需要这个。如果您这边缺少 Application.OpenForms,那是因为您必须使用 System.Windows.Forms.Application.OpenForms
例如:
fc 对象包含以下属性: Count 和 InnerList(非常有用)
希望它有帮助,即使是 2021 年,我认为有人会需要此信息(当我搜索它时,我在任何地方都没有看到它)
I might be late here but just in case someone needs this. If Application.OpenForms is missing on your side, that's because you have to use
System.Windows.Forms.Application.OpenForms
For example:
The fc object contains properties as: Count and InnerList(very useful)
Hope it helps, even if it is 2021, I thought that someone would need this information (I haven't seen it anywhere when I searched for it)