title: Access XAML Instantiated Object from C#
body: <p>In my XAML I declare an instance of a class called DataConnection, the instance is named MyConnection.</p>
  
  <pre><code>&lt;Window.Resources&gt;
          &lt;!-- Create an instance of the DataConnection class called MyConnection --&gt;
          &lt;!-- The TimeTracker bit comes from the xmlns above --&gt;
          &lt;TimeTracker:DataConnection x:Key="MyConnection" /&gt;
          &lt;!-- Define the method which is invoked to obtain our data --&gt;
          &lt;ObjectDataProvider x:Key="Time" ObjectInstance="{StaticResource ResourceKey=MyConnection}" MethodName="GetTimes" /&gt;
          &lt;ObjectDataProvider x:Key="Clients" ObjectInstance="{StaticResource ResourceKey=MyConnection}" MethodName="GetClients" /&gt;
  &lt;/Window.Resources&gt;
  </code></pre>
  
  <p>Everything in the XAML part works fine. What I want is to be able to reference my instance of MyConnection from my C# code.</p>
  
  <p>How is that possible?</p>