我正在尝试通过询问用户文本框的数量来动态添加文本框。此代码正在运行,但将项目添加到当前位置。
NavigationService.Navigate(new Uri("/Page1.xaml?shouldDownload=true", UriKind.Relative)); //Naviagte on new page
int num;
int.TryParse(textBox1.Text, out num); //Converting textbox to int
for (int i = 1; i <= num; i++)
{
TextBox newtext = new TextBox();
newtext.Text = i.ToString();
newtext.Margin = new Thickness(300, (i * 80), 0, 0);
newtext.Width = 124;
newtext.Height = 68;
//button.VerticalAlignment = 234;
//Add contentpanel to your page if there's not one already.
ContentPanel.Children.Add(newtext);
newtext.Visibility = System.Windows.Visibility.Visible;
}
但我想将这些项目添加到不在这里的新页面(即:Page1)。
将拨出帮助。