title: Can I get headers in a WPF grid getting its rows from a data template?
body: <p>I am implementing a headered table using grids above each other, so I can specify columns headers. There is one grid for headers, and one grid for every row in the table. It is not very practical, header widths has to be specified twice. Maybe I instead can have a ListView/DataGrid without all styling?</p>
  
  <p>How can I get rid of this multi Grid approach?</p>
  
  <p>Here is what I got:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;StackPanel Orientation="Vertical"&gt;
    &lt;Grid Margin="0, 10, 0, 0"&gt;
      &lt;Grid.ColumnDefinitions&gt;
        &lt;ColumnDefinition Width="40" /&gt;
        &lt;ColumnDefinition Width="70" /&gt;
      &lt;/Grid.ColumnDefinitions&gt;
      &lt;Grid.RowDefinitions&gt;
        &lt;RowDefinition /&gt;
      &lt;/Grid.RowDefinitions&gt;
      &lt;TextBlock Grid.Column="0" Grid.Row="0"
              Text="header 1" /&gt;
      &lt;TextBlock Grid.Column="1" Grid.Row="0"
              Text="header 2" /&gt;
    &lt;/Grid&gt;
    &lt;ItemsControl ItemsSource="{Binding Entities}"&gt;
      &lt;ItemsControl.ItemTemplate&gt;
        &lt;DataTemplate&gt;
          &lt;StackPanel Orientation="Vertical"&gt;
            &lt;Grid Margin="0, 10, 0, 0"&gt;
              &lt;Grid.ColumnDefinitions&gt;
                &lt;ColumnDefinition Width="40" /&gt;
                &lt;ColumnDefinition Width="70" /&gt;
              &lt;/Grid.ColumnDefinitions&gt;
              &lt;Grid.RowDefinitions&gt;
                &lt;RowDefinition /&gt;
              &lt;/Grid.RowDefinitions&gt;
              &lt;TextBlock Grid.Column="0" Grid.Row="0"
                 Text="{Binding Property1}" /&gt;
              &lt;TextBlock Grid.Column="1" Grid.Row="0"
                 Text="{Binding Property2}" /&gt;
            &lt;/Grid&gt;
          &lt;/StackPanel&gt;
        &lt;/DataTemplate&gt;
      &lt;/ItemsControl.ItemTemplate&gt;
    &lt;/ItemsControl&gt;
  &lt;/StackPanel&gt;
  </code></pre>