title: Get all open WPF windows
body: <p>I'm trying to get all open windows. I tried to use <code>System.Windows.Application.Current.Windows</code> but I get Null Pointer Exception in line where <code>foreach</code> loop is. Do anyone has idea what is wrong?</p>
  
  <pre><code>public Window getWindow(String Title)
  {
      Window windowObject = null;
      Console.WriteLine("Inside getWindow");
      foreach (Window window in System.Windows.Application.Current.Windows)
      {
          if (window.Title == Title)
          {
              windowObject = window;
          }
      }
      return windowObject;
  }
  </code></pre>