WPF查找窗口实例 [英] WPF Find window instance

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

问题描述

我已经在一个类中创建了一个窗口的实例,但是我无法直接从其他类访问该窗口的实例.

I have created an instance of a window inside a class, but I am unable to access the instance of the window from my other class directly.

有没有办法引用我已经使用C#方法创建的窗口实例,也许在打开的应用程序窗口中进行搜索,直到找到我要访问的仪表板窗口?

Is there a way to reference the window instance I have already created using a C# method, perhaps searching through the open app windows until it finds the Dashboard window I am trying to access?

推荐答案

Application.Current.Windows 提供了所有窗口,使用它的类型不难发现.

Application.Current.Windows gives you all windows, shouldn't be hard to find using its type.

(正如Ed所指出的那样,这听起来似乎不是一个很好的设计,所以您可能要考虑一下如何在没有凌乱的窗口引用的情况下完成工作)

这篇关于WPF查找窗口实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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