title: Dynamically generating Row and Column headers for DataGrid using templates WPF
body: <p>I am working on populating a grid using templates, where I do not know the number of rows and columns, these will be generated via a WCF service in a class that looks something like this:</p>
  
  <pre><code> class GridPoint:
      { 
  string Rowheader;
  float cellvalue;
       }
  
  class ColumnData: List&lt;GridPoint&gt;
  {
  
  }
  </code></pre>
  
  <p>So the datagrid code would be something like this:</p>
  
  <pre><code> MyGrid: DataGrid
  {
  InitializeComponent();
   private void DataGrid_AutoGeneratingColumn(objectsender,DataGridAutoGeneratingColumnEventArgs e) 
  {
   var col = new DataGridTextColumn {Binding = new Binding(e.PropertyName), Header = e.PropertyName};
          e.Column = col;
  
  }
  }
  </code></pre>
  
  <p>I found a way to auto generate columns with the data template in <a href="https://stackoverflow.com/questions/20493184/datagridtemplatecolumns-autogeneratecolumns-true-and-binding-to-a-datatable">this</a> post. However, they have no mention of adding the row header for each point. I would appreciate your help in adding a row header to the mix into the column style.</p>
  
  <p>The end product should look something like this:</p>
  
  <pre><code>    Column1   Column2 
  Row1    123       123
  Row2    811       811 
  Row3    123       123
  </code></pre>
  
  <p>A hack I can think of is just generating an extra column with a different style similar to the column header style and adding my row points in it. </p>