title: WPF Close all child window except active child window and main window
body: <p>I have C# WinForms code as follows to close all child forms when I open a new child form:</p>
  <pre><code>private void CloseAllActiveForms(Form[] MdiChildren)
  {
      Form[] childArray = MdiChildren;
      foreach (Form childform in childArray)
      {
          childform.Close();
      }
  }
  </code></pre>
  <p>How can I use in WPF windows?</p>
  <p>I tried the below code, but it will close all windows including the Parent and the Active window.</p>
  <pre><code>private void CloseAllWindows()
  {
      for (int intCounter = App.Current.Windows.Count - 1; intCounter &gt;= 0; intCounter--)
      {
          Application.Current.Windows[intCounter].Close();
      }
  }
  </code></pre>
  <p>Thanks.</p>