我在我的申请得到了另一个窗口,除了我的主窗口和我重写闭合方法是这样,因为我不想让窗口完全关闭:隐藏窗口隐藏主窗口
private void Window_Closing(object sender, CancelEventArgs e)
{
e.Cancel = true;
this.Visibility = Visibility.Hidden;
}
然后在构造函数中:
public Inputwindow()
{
InitializeComponent();
this.Closing += Window_Closing;
}
但是现在如果我想关闭我的MainWindow,它只隐藏MainWindow。
无法弄清楚,如何让它工作。
你想要什么隐藏或关闭? – Marusyk
我相信他不想处置这个窗口。 window_closing事件是在哪里声明的?如果this.visibility = visibility.hidden关闭主窗口意味着这是主窗口,所以你宣布它在错误的地方。 –
@MegaTron在我的主窗口中,我打开另一个窗口,如果我单击此新窗口的关闭按钮,则不应该关闭该窗口。所以我实现了上面的方法来隐藏新窗口。但是现在如果我单击MainWindow上的关闭按钮,它不会关闭整个应用程序。它只是隐藏MainWindow。 –