In PHP web programming, I always made a singleton Output object in which I could put global information that had to be available from any line of code.
So in WPF applications, I create the following class to perform the same function, e.g. the variable ReturnToPageIdCode
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.
This works nicely.
However, I can't help to think that in the stateful WPF environment, I'm recreating the wheel with this singleton Output object.
Where do you put hold application-wide values in your WPF applications? Is there some standard place to do this?
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.";
}
}