creating a class like App.xaml.cs in Class Library Project
<p>So recently; I refactored <code>Views</code> to their own <code>WPF Application</code> project and I moved my <code>ViewModel</code> classes into their own Class Library project. This worked well for keeping my code in order. Then I realised that I didn't have the comfort of the <code>App.xaml.cs</code> class.</p>

<p>This class (for me) meant that I could declare all sorts of objects and access them application wide.</p>

<p>i.e: In the App.xaml.cs</p>

<pre><code>public partial class App : Application
{
    public myDatabaseEntities context { get; set; }

    // App.xaml.cs Constructor
    public App()
    {
        context = new myDatabaseEntities();
    }
}
</code></pre>

<p>In some random View Model:</p>

<pre><code>myDatabaseEntities context = ((App)Application.Current).context;
</code></pre>

<p>The above allows me to recylce the instance, and comes in particularly handy with Unity's (IoC container) version of lifetime manager.</p>

<p>Thing is, I'm not sure on how to achieve this behaviour within a class Library project. I'm not sure how to create a class that instantiates at runtime. And I have no clue how to pass that <code>App</code> class instance around to relevant classes. Any ideas on how to do this? Any help would be much appreciated.</p>