title: Access ResourceDictionary items programmatically
body: <p>I have a Silverlight controls assembly, called "MySilverlightControls". Several folders down into that assembly I have a class which extends a grid column from a third party vendor, let's call it "MyImageColumn.cs".</p>
  
  <p>I have also created a resource dictionary called <code>Generic.xaml</code>, this is situated in the <code>Themes</code> folder of the assembly. In that resource dictionary i have defined a ControlTemplate called <i>MyImageColumnTemplate</i>:</p>
  
  <pre><code>&lt;ControlTemplate x:Name="MyImageColumnTemplate" &gt;
      &lt;Grid Margin="8,8,4,4" MaxHeight="32" MaxWidth="32"&gt;
          &lt;Grid.Resources&gt;
              &lt;localGrid:StatusColumnImageConverter x:Key="ImageContentConverter"/&gt;
          &lt;/Grid.Resources&gt;
          &lt;Border Margin="5,5,0,0" Background="Black" Opacity="0.15" CornerRadius="5" /&gt;
          &lt;Border Background="#FF6E6E6E" CornerRadius="4,4,4,4" Padding="4" Margin="0,0,5,5"&gt;
              &lt;Border Background="White" CornerRadius="2,2,2,2" Padding="3"&gt;
                  &lt;Image Source="{Binding EditValue, Converter={StaticResource ImageContentConverter}}" Stretch="Uniform"/&gt;
              &lt;/Border&gt;
          &lt;/Border&gt;
      &lt;/Grid&gt;
  &lt;/ControlTemplate&gt;
  </code></pre>
  
  <p>My question is: from MyImageColumn, how can I programmatically reference/load this control template so I can assign it to a property on the column? I would expect to be using a syntax similar to this:</p>
  
  <pre><code>ControlTemplate ct = (ControlTemplate)Application.Current.Resources["MyImageColumnTemplate"];
  </code></pre>
  
  <p>but this always returns null. When I load the assembly up in Reflector, I see that the <code>Generic.xaml</code> file is there, the name of the resource is <code>MySilverlightControls.g.resources</code>, and the path within that is <code>themes/generic.xaml</code>.</p>
  
  <p>How exactly can I get to the individual items in this resource dictionary?</p>