Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在WPF应用程序中打开窗体窗口_C#_Wpf - Fatal编程技术网

C# 在WPF应用程序中打开窗体窗口

C# 在WPF应用程序中打开窗体窗口,c#,wpf,C#,Wpf,我想获得混合应用程序的所有打开窗口(WPF)和表单(WF)。 有一种方法叫做Application.Current.Windows。。。但它只返回WPF窗口 注意:Windows窗体存储在解决方案中的其他项目(DLL)中。您可以通过访问Windows窗体打开的窗体。该属性包含在System.Windows.Forms.dll程序集中,因此需要对其进行引用 (IIRC,此属性仅返回在当前线程上创建的表单;因此,如果您有两个单独的UI线程(一个用于Windows窗体,一个用于WPF),我相信您需要在

我想获得混合应用程序的所有打开窗口(WPF)和表单(WF)。 有一种方法叫做
Application.Current.Windows
。。。但它只返回WPF窗口


注意:Windows窗体存储在解决方案中的其他项目(DLL)中。

您可以通过访问Windows窗体打开的窗体。该属性包含在
System.Windows.Forms.dll
程序集中,因此需要对其进行引用

(IIRC,此属性仅返回在当前线程上创建的表单;因此,如果您有两个单独的UI线程(一个用于Windows窗体,一个用于WPF),我相信您需要在Windows窗体的UI线程上调用此属性。)

检查此msdn 希望你能找到你想要的。 它也有例子


为此,您必须使用

                foreach (Window win in System.Windows.Application.Current.Windows)
    {
       win..title;
    }  

这是VB.NET特有的,这个问题被标记为C#。即使它可以在C#应用程序中工作,也比严格要求的工作要多:您必须以某种方式获得对
WindowsFormsApplicationBase
对象的引用,然后才能访问其
OpenForms
属性。但是有一个类似的静态属性根本不依赖于
WindowsFormsApplicationBase
;看看我的答案。