title: Get text of a text box that was created at runtime
body: <p>In my app, I create a text box at the runtime, here is the code</p>
  
  <pre><code>TextBox bt = new TextBox();
  bt.Name = "population_textbox";
  bt.Height = 20;
  bt.SetValue(Grid.ColumnProperty, 1);
  bt.SetValue(Grid.RowProperty, 0);
  temp_grid.Children.Add(bt);
  </code></pre>
  
  <p>So, how to get the Text of this text box after user type something and enter. I don't know how to do it, I try</p>
  
  <pre><code>var tb = (FrameworkElement)this.FindName("population_textbox") as TextBox;
  Console.Write(tb.Text);
  </code></pre>
  
  <p>And this is the error alert: </p>
  
  <pre><code>Exception has been thrown by the target of an invocation.
  </code></pre>