title: Set binding code behind for the DataTemplate does not work in WPF
body: <p>I have to bind dynamic the Text property for the TextBlock in the WPF application in the runtime.
  Here is the code:</p>
  
  <p>In xaml file</p>
  
  <pre><code>&lt;DataTemplate x:Key="Double_View_Template"&gt;
      &lt;TextBlock
          x:Name="txtDoubleViewTemplate" 
          HorizontalAlignment="Left"
          VerticalAlignment="Center" 
          /&gt;
  &lt;/DataTemplate&gt;
  </code></pre>
  
  <p>In C#</p>
  
  <pre><code>DataTemplate data = FindResource("Double_View_Template") as DataTemplate;
  TextBlock ui = data.LoadContent() as TextBlock;
  Binding binding = new Binding();
  binding.Path = new PropertyPath("Mass");
  BindingOperations.SetBinding(ui, TextBlock.TextProperty, binding);
  
  DataGridTemplateColumn column = new DataGridTemplateColumn();
  column.CellTemplate = data;
  instrumentDataGrid.Columns.Add(column);
  </code></pre>
  
  <p>When run the application I see only blank lines, and the values are not shown in the Datagrid. The ItemsSource and the DataContext is correctly set.
  If I set</p>
  
  <pre><code> Text="{Binding Path=Mass}" 
  </code></pre>
  
  <p>in the xaml the data is displayed.</p>
  
  <p>Any idea why in the runtime the binding is not set?</p>