title: C# fill Dynamic Grid with TextBox, Button and more in WPF
body: <ul>
  <li>VS2010 -C#
  I have a TextBox where you can input an integer and a UniformGrid is dynamically generated with the integer number of UniformGrid Cells. Now if I want to add a TextBox to each UniformGrid Cell, I do the following (e.g. int is a 5):</li>
  </ul>
  
  <blockquote>
    <p>TextBox[] tb = new TextBox[5];<br/>
     for (int i = 0; i &lt; 5; i++)<br/>
                {<br/>
                    tb[i] = new Textbox();<br/>
                    UniformGrid1.Children.Add(tb[i]);<br/>
                }<br/></p>
  </blockquote>
  
  <p>Ok..that works fine.  But problem comes when I need also to fill in some more Texboxes, Buttons, and Labels in it with some design properties defined, possibly also insert a grid inside a UniformGrid Cell. It will get extremely messy if I create arrays for each control and define each array properties in the loop.
  Not only that it's messy, I cannot put the textbox inside the UniformGrid's Cell's Grid. The children add the grid on top of the TextBox instead.</p>
  
  <p>Is there a better way to approach this?</p>