【问题标题】:how can i get the parent of user control wpf我怎样才能获得用户控件wpf的父级
【发布时间】:2010-09-16 08:44:18
【问题描述】:

我有一个问题,我制作了一个窗口应用程序并在我的窗口窗体上使用了一些 Wpf 用户控件我想关闭我的窗体当我关闭用户控件时,取消按钮我怎样才能实现它.....意味着我想要获取usercontrol的父级

【问题讨论】:

    标签: c# wpf


    【解决方案1】:

    UserControl 的父级通过 Parent 属性获得。可以直接用Window.GetWindow-方法得到的窗口。

    Window w=Window.GetWindow(this);
    if(null != w){
        w.Close();
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-06-04
      • 2017-05-25
      • 1970-01-01
      • 2015-04-06
      • 1970-01-01
      • 1970-01-01
      • 2018-04-05
      • 2023-03-21
      相关资源
      最近更新 更多