title: WPF Error: Cannot find governing FrameworkElement for target element
body: <p>I've got a <code>DataGrid</code> with a row that has an image. This image is bound with a trigger to a certain state. When the state changes I want to change the image.</p>
  
  <p>The template itself is set on the <code>HeaderStyle</code> of a <code>DataGridTemplateColumn</code>. This template has some bindings. The first binding Day shows what day it is and the State changes the image with a trigger.</p>
  
  <p>These properties are set in a ViewModel. </p>
  
  <p>Properties:</p>
  
  <pre class="lang-cs prettyprint-override"><code>public class HeaderItem
  {
      public string Day { get; set; }
      public ValidationStatus State { get; set; }
  }
  
  this.HeaderItems = new ObservableCollection&lt;HeaderItem&gt;();
  for (int i = 1; i &lt; 15; i++)
  {
      this.HeaderItems.Add(new HeaderItem()
      {
          Day = i.ToString(),
          State = ValidationStatus.Nieuw,
      });
  }
  </code></pre>
  
  <p>Datagrid:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;DataGrid x:Name="PersoneelsPrestatiesDataGrid" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
                AutoGenerateColumns="False" SelectionMode="Single" ItemsSource="{Binding CaregiverPerformances}" FrozenColumnCount="1" &gt;
  
      &lt;DataGridTemplateColumn HeaderStyle="{StaticResource headerCenterAlignment}" Header="{Binding HeaderItems[1]}" Width="50"&gt;
          &lt;DataGridTemplateColumn.CellEditingTemplate&gt;
              &lt;DataTemplate&gt;
                  &lt;TextBox Text="{ Binding Performances[1].Duration,Converter={StaticResource timeSpanConverter},Mode=TwoWay}"/&gt;
              &lt;/DataTemplate&gt;
          &lt;/DataGridTemplateColumn.CellEditingTemplate&gt;
  
          &lt;DataGridTemplateColumn.CellTemplate&gt;
              &lt;DataTemplate&gt;
                  &lt;TextBlock TextAlignment="Center" Text="{ Binding Performances[1].Duration,Converter={StaticResource timeSpanConverter}}"/&gt;
              &lt;/DataTemplate&gt;
          &lt;/DataGridTemplateColumn.CellTemplate&gt;
      &lt;/DataGridTemplateColumn&gt; 
  &lt;/DataGrid&gt;
  </code></pre>
  
  <p>Datagrid HeaderStyleTemplate:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;Style x:Key="headerCenterAlignment" TargetType="{x:Type DataGridColumnHeader}"&gt;
      &lt;Setter Property="HorizontalContentAlignment" Value="Center"/&gt;
  
      &lt;Setter Property="Template"&gt;
          &lt;Setter.Value&gt;
              &lt;ControlTemplate TargetType="{x:Type DataGridColumnHeader}"&gt;
                  &lt;Grid&gt;
                      &lt;Grid.RowDefinitions&gt;
                          &lt;RowDefinition /&gt;
                          &lt;RowDefinition /&gt;
                      &lt;/Grid.RowDefinitions&gt;
  
                      &lt;TextBlock Grid.Row="0" Text="{Binding Day}" /&gt;
                      &lt;Image x:Name="imageValidation" Grid.Row="1" Width="16" Height="16" Source="{StaticResource imgBevestigd}" /&gt;
                  &lt;/Grid&gt;
  
                  &lt;ControlTemplate.Triggers&gt;
                      &lt;MultiDataTrigger &gt;
                          &lt;MultiDataTrigger.Conditions&gt;
                              &lt;Condition Binding="{Binding State}" Value="Nieuw"/&gt;                                 
                          &lt;/MultiDataTrigger.Conditions&gt;
                          &lt;Setter TargetName="imageValidation" Property="Source" Value="{StaticResource imgGeenStatus}"/&gt;
                      &lt;/MultiDataTrigger&gt;
                  &lt;/ControlTemplate.Triggers&gt;
              &lt;/ControlTemplate&gt;
          &lt;/Setter.Value&gt;
      &lt;/Setter&gt;
  &lt;/Style&gt;
  </code></pre>
  
  <p>Now when I startup the project the images doesn't show and I get this error:</p>
  
  <blockquote>
    <p>System.Windows.Data Error: 2 : Cannot find governing FrameworkElement or FrameworkContentElement for target element. BindingExpression:Path=HeaderItems[0]; DataItem=null; target element is 'DataGridTemplateColumn' (HashCode=26950454); target property is 'Header' (type 'Object')</p>
  </blockquote>
  
  <p>Why is this error showing?</p>