简体   繁体   English

我怎样才能获得用户控件wpf的父级

[英]how can i get the parent of user control wpf

我有一个问题,我做一个窗口应用程序,并在我的窗口窗体上使用一些Wpf用户控件我要关闭我的窗体当我关闭用户控件,取消按钮我怎么能得到它.....意味着我想得到usercontrol的父级

The parent of the UserControl you get with the Parent -property. 使用Parent -property获得的UserControlParent The window you can get directly with the Window.GetWindow -method. 您可以直接使用Window.GetWindow -method获取的窗口。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在拉伸其父窗口时垂直拉伸WPF用户控件及其组件 - How can I vertically stretch a WPF user control and its components while stretching its parent window 如何在wpf中从子用户控件访问父usercontrols元素? - How can I access the parent usercontrols elements from the child user control in wpf? 如何从父表单中的用户定义控件获取控件的值 - How can I get values of a control from the user-defined control in the parent form WPF 用户控件父级 - WPF User Control Parent 我可以通过绑定到wpf父控件上的属性的依赖项属性在xaml中设置用户控件datacontext吗? - Can I set my user control datacontext in xaml via a dependency property bound to a property on the parent control in wpf? 如何从ASP.NET网站(而不是Web应用程序)中的用户控件获取父页面 - How can I get the parent page from a User Control in an ASP.NET Website (not Web Application) 如何在wpf用户控件中监听INotifyCollectionChanged - How can I listen to INotifyCollectionChanged in a wpf user control 如何对WPF用户控件的视图模型进行单元测试 - How can I unit test the view models of a WPF user control 如何与WPF用户控件中托管的Delphi窗口通信? - How can I communicate with a Delphi window hosted in a WPF User Control? 如何重用WPF用户控件但更改绑定属性? - How can I reuse a WPF user control but change a bound property?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM