Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/333.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窗口 当我想打开一个新窗口时,我将关闭当前窗口,并加载一个新窗口: ProductMain productMain= new ProductMain(); productMain.Show(); this.Close(); 我知道你们可以把用户控件放到窗口中 我可以在主窗口中加载窗口吗 谢谢。您可以通过设置窗口的所有者属性来执行类似操作。要获取主窗口,请使用: Application.Current.MainWindow 之后,您可以设置ProductMain窗口的: Pr

我几乎没有WPF窗口

当我想打开一个新窗口时,我将关闭当前窗口,并加载一个新窗口:

ProductMain productMain= new ProductMain();
productMain.Show();
this.Close(); 
我知道你们可以把用户控件放到窗口中

我可以在主窗口中加载窗口吗


谢谢。

您可以通过设置窗口的所有者属性来执行类似操作。要获取主窗口,请使用:

Application.Current.MainWindow
之后,您可以设置ProductMain窗口的:

ProductMain productMain= new ProductMain();
productMain.Owner = Application.Current.MainWindow;
productMain.Show();