title: Add DataTemplate to grid programmatically
body: <p>I'm using Telerik Grid in my WPF application. If I define everything in XAML, it works fine, also the image column:</p>
  
  <pre><code> &lt;!-- IsActiveGroup --&gt;
   &lt;telerik:GridViewDataColumn DataMemberBinding="{Binding IsActiveGroup}" Width="45"&gt;
        &lt;telerik:GridViewDataColumn.Header&gt;
             &lt;TextBlock Text="Column name" ToolTip="Some tooltip"/&gt;
        &lt;/telerik:GridViewDataColumn.Header&gt;
        &lt;telerik:GridViewDataColumn.CellTemplate&gt;
             &lt;DataTemplate&gt;
                  &lt;Image Source="{Binding Path=IsActiveImageSource, Converter={StaticResource imgConverter}}" Stretch="UniformToFill" RenderOptions.BitmapScalingMode="HighQuality" Width="20" Height="20" ToolTip="{Binding IsActiveGroup}" /&gt;
             &lt;/DataTemplate&gt;
        &lt;/telerik:GridViewDataColumn.CellTemplate&gt;
   &lt;/telerik:GridViewDataColumn&gt;   
  </code></pre>
  
  <p>However, I have to do this programmatically, but I don't know how this can be done. I tried:</p>
  
  <pre><code> var column = new GridViewDataColumn();    
   column.UniqueName = uniqueName;
   var headerTextBlock = new TextBlock();
   headerTextBlock.Text = headerText;
   headerTextBlock.ToolTip = headerTooltip;
   column.Header = headerTextBlock;
  
   var factory = new FrameworkElementFactory(typeof(Image));
   factory.SetValue(Image.SourceProperty, new Binding("IsActiveImageSource")
           {
              Converter = new BinaryImageConverter()
           });
   factory.SetValue(Image.StretchProperty, Stretch.UniformToFill);
   var cellTemplate = new DataTemplate() { VisualTree = factory };
   column.CellTemplate = cellTemplate;
   this.gridView.Columns.Add(column);
  </code></pre>
  
  <p>But this is not doing anything and I also don't know how to set the RenderOptions.</p>
  
  <p>Can anyone help?</p>
  
  <p>Thanks!</p>