title: Where do you put global variables in a WPF application?
body: <p>In <strong>PHP</strong> web programming, I always made a <strong>singleton Output object</strong> in which I could put <strong>global</strong> information that had to be available from any line of code.</p>
  
  <p>So in <strong>WPF</strong> applications, I create the following class to perform the same function, e.g. the variable <strong><code>ReturnToPageIdCode</code></strong> returns the page to which another page is supposed to return to after processing some task, and I can set and get that value anywhere I want.</p>
  
  <p>This works nicely.</p>
  
  <p>However, I can't help to think that in the <strong>stateful</strong> WPF environment, I'm <strong>recreating the wheel</strong> with this singleton Output object.</p>
  
  <p><strong>Where do you put hold application-wide values in your WPF applications? Is there some standard place to do this?</strong></p>
  
  <pre><code>public class Output
  {
      private Output output;
  
      private static Output instance;
  
      public string ReturnToPageIdCode { get; set; }
  
      public static Output GetInstance()
      {
          if (instance == null)
          {
              instance = new Output();
          }
          return instance;
      }
  
      public string GetTestMessage()
      {
          return "This is a global test message from the output singleton.";
      }
  }
  </code></pre>