title: How to add items to XAML/WINRT Grid from Code
body: <p>So, I am trying to create a grid that can be dynamically populated by 0 to X items depending on when the Frame is open.</p>
  
  <p>I read the MSDN article on how to create a grid and add to it in code:
  <a href="http://msdn.microsoft.com/en-us/library/ms752271.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms752271.aspx</a></p>
  
  <p>Howeverm I want to create the Grid in the XAML and add to it in the code.  Something like this:</p>
  
  <p>XAML:</p>
  
  <pre><code>&lt;Grid x:Name="ManagePhotosContent" Grid.Row="1" Visibility="Visible"&gt;
  &lt;!-- to be filled in by code --&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p>In C# code i am doing something like this:</p>
  
  <pre><code>rowDef = new RowDefinition();
  ManagePhotosContent.RowDefinitions.Add(rowDef);
  textBlock = new TextBlock();
  
  // i is an incrementer
  textBlock.Text = string.Format("The is iteration {0}, i);
  ManagePhotosContent.SetRow(textBlock, i);
  </code></pre>
  
  <p>However, SetRow is not an available function or property of the ManagePhotosContent grid that I created in XAML.  Further, I am unable to see how to set up the RowDefinition in code to be of Height="*".  Am I doing something wrong here?</p>