title: Why won't this change the color of my WPF Datagrid headers?
body: <p>I fill my datagrid in code behind like this:</p>
  
  <pre><code>var customers = from c in _db.Customers
                  select c;
  TheDataGrid.ItemsSource = customers.ToList();
  </code></pre>
  
  <p>In my XAML below, the DataGrid.RowBackground works but <strong>the DataGridHeaderBorder gets the error "The Items listing must be empty before the use of ItemsSource"</strong> in the code-behind upon runtime.</p>
  
  <p>This is odd because I'm just trying to change the color of the Datagrid headers and it gets a problem with ItemsSource. If I take the DataGridHeaderBorder line out, it works fine.</p>
  
  <p><strong>So how does one simply change the color of the column headers on a Datagrid?</strong></p>
  
  <p></p>
  
  <pre><code>        &lt;toolkit:DataGridHeaderBorder Background="yellow"/&gt;
  
          &lt;toolkit:DataGrid.RowBackground&gt;
              &lt;LinearGradientBrush EndPoint="-0.136,-0.163" StartPoint="1.291,1.248"&gt;
                  &lt;GradientStop Color="#FFA8A929" Offset="0.004"/&gt;
                  &lt;GradientStop Color="#FFF7F7ED" Offset="0.991"/&gt;
              &lt;/LinearGradientBrush&gt;
          &lt;/toolkit:DataGrid.RowBackground&gt;
  </code></pre>