title: Problem creating Silverlight Grid columns programmatically on WP7
body: <p>I'm trying to create a user control which will allow me to pass in a list of column definitions and which will create a grid for me.</p>
  
  <p>So far nothing is displaying. Here is the code:</p>
  
  <pre><code>List&lt;GridColumn&gt; colList = new List&lt;GridColumn&gt;();
  GridColumn col1 = new GridColumn(200, "AAA");
  colList.Add(col1);
  GridColumn col2 = new GridColumn(200, "BBB");
  colList.Add(col2);
  
  BuildColumns(MainGrid, colList)
  
  
  private void BuildColumns(Grid mainGrid, List&lt;GridColumn&gt; gridColumnList)
  {
      // create grid columns
      foreach (GridColumn gridColumn in gridColumnList)
      {
          GridLength len = new GridLength(gridColumn.ColumnWidth);
          ColumnDefinition col = new ColumnDefinition {Width = len};
          mainGrid.ColumnDefinitions.Add(col);
      }
  
      // add 2 rows
      GridLength height = new GridLength(100);
      RowDefinition rowDef1 = new RowDefinition {Height = height};
      mainGrid.RowDefinitions.Add(rowDef1);
      RowDefinition rowDef2 = new RowDefinition {Height = height};
      mainGrid.RowDefinitions.Add(rowDef2);
  
      // add text blocks to cells
      int colNum = -1;
      foreach (GridColumn gridColumn in gridColumnList)
      {
          colNum++;
          TextBlock textBlock = new TextBlock();
          textBlock.Text = gridColumn.ColumnName;
          Grid.SetRow(textBlock, 0);
          Grid.SetColumn(textBlock, colNum);
      }
  }
  </code></pre>
  
  <p>I have tried increasing the row/column size and refreshing the grid.</p>
  
  <p>This is the same as <a href="https://stackoverflow.com/questions/3975948/wp7-silverlight-grid-not-showing-content">this earlier question</a> but the answer did not fix my problem.</p>
  
  <p>This is what it looks like on the phone</p>
  
  <p><img src="https://i.stack.imgur.com/KmNCk.jpg" alt="enter image description here"></p>