XX.MainWindow=>是想要保留窗体的命名
/// <summary>
/// 关闭非装窗体以外所有窗体
/// </summary>
private void CloseForm()
{
int n = Application.Current.Windows.Count;
for (int a = 0; a < n; a++)
{
for (int i = 0; i < Application.Current.Windows.Count; i++)
{
string x = Application.Current.Windows[i].ToString();
if (x != "XX.MainWindow") Application.Current.Windows[i].Close();
}
}
}