title: DataGrid RowHeader set programmatically - text is blank but content is set
body: <p>I am creating a DataGrid programmatically, which is working fine, but the RowHeaders are not showing properly. The text is apparently there because the tooltip shows the right content but it's showing blank in the header. Apparently I cannot post a screen shot - it shows a grid with 10 or so rows, header is 150 wide, but nothing in them, then several columns of data.</p>
  
  <p>Here's the code that creates the DataGrid:</p>
  
  <pre><code>            seisTraceHeaderGrid = new DataGrid
          {
              AutoGenerateColumns = false,
              HorizontalAlignment = HorizontalAlignment.Stretch,
              VerticalAlignment = VerticalAlignment.Stretch,
              HorizontalScrollBarVisibility = ScrollBarVisibility.Visible,
              VerticalScrollBarVisibility = ScrollBarVisibility.Visible,
              HorizontalContentAlignment = HorizontalAlignment.Stretch,
              HeadersVisibility = DataGridHeadersVisibility.All,
              IsReadOnly = true,
              CanUserAddRows = false,
              CanUserDeleteRows = false,
              CanUserReorderColumns = false,
              CanUserResizeColumns = true,
              CanUserResizeRows = true,
              CanUserSortColumns = false,
              SelectionMode = DataGridSelectionMode.Single,
              SelectionUnit = DataGridSelectionUnit.Cell,
              RowHeight = 25,
              ColumnWidth = 75,
          };
  
          seisTraceHeaderGrid.AlternatingRowBackground = (Brush)Resources["AlternateRowBackgroundBrush"];
          seisTraceHeaderGrid.ColumnHeaderStyle = (Style)Resources["ColumnHeaderStyle"];
          seisTraceHeaderGrid.LoadingRow += dg_LoadingRow;
  
          // set up the row headers
          DataTemplate rowHeaderTemplate = new DataTemplate();
          rowHeaderTemplate.DataType = typeof(RowHeaderNode);
          FrameworkElementFactory textHolder = new FrameworkElementFactory(typeof(Label));
          textHolder.SetBinding(ContentProperty, 
              new Binding("RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type DataGridRow}}, Path=Header"));
          rowHeaderTemplate.VisualTree = textHolder;
          seisTraceHeaderGrid.RowHeaderTemplate = rowHeaderTemplate;
  
          // add a column for each trace
          for (int traceId = 0; traceId &lt; ViewModel.Nodes[0].Count; traceId++) {
              seisTraceHeaderGrid.Columns.Add(
                  new DataGridTextColumn
                      {
                          Header = string.Format(" {0}", traceId + 1),
                          Binding = new Binding(string.Format("[{0}]", traceId))
                      }
                  );
          }
          // add some dummy columns to make it prettier
          for (int traceId = ViewModel.Nodes[0].Count; traceId &lt; 5; traceId++) {
  
              seisTraceHeaderGrid.Columns.Add(
                  new DataGridTextColumn
                      {
                          Header = string.Format(" {0}", ""),
                          Binding = new Binding(string.Format("[{0}]", ""))
                      }
                  );
          }
  
          seisTraceHeaderGrid.RowHeaderWidth = 150;
          seisTraceHeaderGrid.ItemsSource = ViewModel.Nodes;
  
          baseGrid.Children.Add(seisTraceHeaderGrid);
  </code></pre>
  
  <p>And the method for putting the text in the RowHeader label:</p>
  
  <pre><code>    private void dg_LoadingRow(object sender, DataGridRowEventArgs e)
      {
          e.Row.Header = string.Format("[{0:000}]", ViewModel.RowHeaders[e.Row.GetIndex()].Offset) + " : " + ViewModel.RowHeaders[e.Row.GetIndex()].Name;
      }
  </code></pre>
  
  <p>What I am not doing? TIA!</p>
  
  <p>Janene</p>