title: Exception when setting the CellStyle property
body: <p>In SL4 when setting the CellStyle for a DataGridTemplateColumn from code I get this exception:</p>
  
  <p>MS.Internal.WrappedException: The type initializer for 'Missing template.  Cannot initialize System.Windows.Controls.DataGridTemplateColumn.' threw an exception.</p>
  
  <p>The code looks like this:</p>
  
  <pre><code>grdMain.IsReadOnly = true;   
  DataGridTemplateColumn templateColumn = new DataGridTemplateColumn();  templateColumn.HeaderStyle = (Style)this.Resources["ImageColumnHeaderStyle"]; 
  
  templateColumn.CellStyle = (Style)this.Resources["CellStyle1"];  // This causes the exception   
  
  //templateColumn.CellTemplate = (DataTemplate)this.Resources["DataTemplate1"];  // This works!      
  
  grdMain.Columns.Add(templateColumn);
  </code></pre>
  
  <p>The markup is quite simple:</p>
  
  <pre><code>&lt;Control.Resources&gt;
  
     &lt;Style x:Key="ImageColumnHeaderStyle" TargetType="sdk:DataGridColumnHeader"&gt;
      ...
     &lt;/Style&gt;        
  
     &lt;DataTemplate x:Key="DataTemplate1"&gt; 
        &lt;TextBlock&gt;abcde&lt;/TextBlock&gt;     
     &lt;/DataTemplate&gt;       
  
    &lt;Style x:Key="CellStyle1"  TargetType="sdk:DataGridCell"&gt; 
     &lt;Setter Property="Template" Value="{StaticResource DataTemplate1}"&gt;                 
  &lt;/Setter&gt;
  
    &lt;/Style&gt;
  &lt;/Control.Resources&gt;
  
     &lt;Grid x:Name="LayoutRoot"&gt;
         &lt;sdk:DataGrid AutoGenerateColumns="False" Height="413" Name="grdMain" Width="335" /&gt;
     &lt;Grid&gt;
  </code></pre>
  
  <p>Since the style does nothing but setting the template to DataTemplate1, I am really puzzled!</p>
  
  <p>Why does it work when I set the CellTemplate from code but not when I set it through the CellStyle property?</p>
  
  <p>Thanks </p>
  
  <p>//Peter</p>