The deeper I dive into WPF the more I am impressed by how the WPF team combined what I liked about WinForms programming and what I like about Web programming. The Application object in WPF is a great example of this. It reminds me of the Application and Session object of ASP.NET wrapped up into one.
The first thing is that there is only one Application class instance per application domain and that the class itself is implemented as a singleton unlike in WinForms where the Application class is just a series of static methods and properties providing access into the underpinnings of Win32. This has the same feel as the Application object in ASP.NET and it’s scope to a virtual directory (hence application domain). The fact that this class is an instance based class opens the door for some really cool features that can help you out with everyday tasks.
In earlier versions of Windows programming sharing data between forms required custom coding and a lot of things to think about. In WPF the Application class has a Properties property that acts much like the Session object in ASP.NET. It is a Dictionary type that allows you to store data from page to page. Just like in an ASP.NET application. This provides you with a much easier way to share data between pages and you get it in the WPF framework out of the box.
If this wasn’t enough how about the ability to store data between invocations of your WPF application. It just so happens WPF has a cookie concept using Name/Value pairs and even has the ability to set expiration of the cookie. I know this has been around in ASP and ASP.NET for a while but it’s the simple things that count the most.
By no means is this all that the Application class has to offer. After all it is the main class for all WPF applications. To learn more about this class refer to the online version of the Windows SDK and look at the Application Object.