我如何通知wpf拥有的关闭窗口?

时间:2011-07-13 19:44:01

标签: c# .net wpf

如果我设置一个拥有的窗口:

OwnedWindow ownedWindow = new OwnedWindow();
ownedWindow.Owner = this;
ownedWindow.Show();

有可能获得关于所拥有的窗口关闭的通知吗?

1 个答案:

答案 0 :(得分:4)

OwnedWindow ownedWindow = new OwnedWindow();
ownedWindow.Owner = this;
ownedWindow.Closing += new System.ComponentModel.CancelEventHandler(ownedWindow_Closing);
ownedWindow.Show();

此处理程序应位于所有者窗口中。

void ownedWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{

}