Shashank
Shashank

Reputation: 6367

how can i get the parent of user control wpf

i have a problem i make a window application and using some Some Wpf user control on my Window Form i want to close my form When I close the user Control,Cancel button how can i achive it.....means i want to get the parent of usercontrol

Upvotes: 5

Views: 4279

Answers (1)

HCL
HCL

Reputation: 36815

The parent of the UserControl you get with the Parent-property. The window you can get directly with the Window.GetWindow-method.

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

Upvotes: 8

Related Questions