【问题标题】:WPF window in a main window主窗口中的 WPF 窗口
【发布时间】:2012-10-03 22:37:24
【问题描述】:

我的 WPF 窗口很少。

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

ProductMain productMain= new ProductMain();
productMain.Show();
this.Close(); 

我知道你可以把用户控制放到窗口中。

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

谢谢。

【问题讨论】:

    标签: c# wpf


    【解决方案1】:

    你可以通过设置 Window 的 owner 属性来做类似的事情。要获取主窗口,请使用:

    Application.Current.MainWindow
    

    之后,您可以设置ProductMain窗口的owner

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

    【讨论】:

      猜你喜欢
      • 2015-08-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-15
      相关资源
      最近更新 更多