title: How to add text in row header using code behind for DataGrid in C# WPF
body: <p>I have a DataGrid which is populated with an array.
  How do I add text in row header using code behind?
  So far I've added data like this.</p>
  <pre><code>public static DataView GetBindable2DArray&lt;T&gt;(T[,] array)
      {
          DataTable dataTable = new DataTable();
          for (int i = 0; i &lt; array.GetLength(1); i++)
          {
              dataTable.Columns.Add(i.ToString(), typeof(Ref&lt;T&gt;));
          }
          for (int i = 0; i &lt; array.GetLength(0); i++)
          {
              DataRow dataRow = dataTable.NewRow();
              dataTable.Rows.Add(dataRow);
          }
          DataView dataView = new DataView(dataTable);
          for (int i = 0; i &lt; array.GetLength(0); i++)
          {
              for (int j = 0; j &lt; array.GetLength(1); j++)
              {
                  int a = i;
                  int b = j;
                  Ref&lt;T&gt; refT = new Ref&lt;T&gt;(() =&gt; array[a, b], z =&gt; { array[a, b] = z; });
                  dataView[i][j] = refT;
              }
          }
          return dataView;
      }
  </code></pre>
  <p>The XAML</p>
  <pre><code>&lt;DataGrid x:Name=&quot;tableDataGrid&quot; Grid.Row=&quot;0&quot; Grid.RowSpan=&quot;6&quot; Grid.Column=&quot;0&quot; 
                AutoGenerateColumns=&quot;True&quot;
                ColumnWidth=&quot;*&quot;
                VerticalScrollBarVisibility=&quot;Visible&quot;
                RowHeaderWidth=&quot;100&quot; SelectionMode=&quot;Extended&quot; SelectionUnit=&quot;Cell&quot;
                 HeadersVisibility=&quot;All&quot; CanUserAddRows=&quot;False&quot;&gt;
        
      &lt;/DataGrid&gt;
  </code></pre>
  <p>ItemSource</p>
  <pre><code>            tableDataGrid.ItemsSource = GetBindable2DArray&lt;double&gt;(dataArray);
  </code></pre>