【发布时间】:2020-07-23 00:11:29
【问题描述】:
SignInWindow signIn= new SignInWindow();
signIn.ShowDialog();
以上代码在我的 MainWindow 类中。
当显示新窗口时,我希望关闭当前窗口。最好的方法是什么?
我的应用程序是 C# WPF 应用程序
我已经尝试过了,但是当它被调用时,我的应用程序退出了
static private void CloseAllWindows()
{
for (int intCounter = App.Current.Windows.Count - 1; intCounter >= 0; intCounter--)
App.Current.Windows[intCounter].Close();
}
【问题讨论】:
-
在你的窗口中关闭... this.Close();或引用 thatWindow.Close();