草庐IT

SignInWindow

全部标签

c# - 启动新窗口时如何关闭当前窗口(在代码中)

SignInWindowsignIn=newSignInWindow();signIn.ShowDialog();上面的代码在我的MainWindow类中。当显示新窗口时,我希望关闭当前窗口。执行此操作的最佳方法是什么?我的应用程序是C#WPF应用程序我试过了,但是当它被调用时,我的应用程序退出了staticprivatevoidCloseAllWindows(){for(intintCounter=App.Current.Windows.Count-1;intCounter>=0;intCounter--)App.Current.Windows[intCounter].Close()