私のアプリでは、実行時にテキスト ボックスを作成します。コードは次のとおりです。
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);
したがって、ユーザーが何かを入力して入力した後に、このテキスト ボックスのテキストを取得する方法は次のとおりです。やり方がわからない、やってみる
var tb = (FrameworkElement)this.FindName("population_textbox") as TextBox;
Console.Write(tb.Text);
そして、これはエラーアラートです:
Exception has been thrown by the target of an invocation.