I have Added buttons on my page in a canvas on the screen, so when I click 'Add Title' it will add a text box in a certain position and when I click Add Question it will do the same thing.
Here is the code I have which preforms this action.
public void AddTitle_Click(object sender, RoutedEventArgs e)
{
TextBox x = new TextBox();
x.Name = "new_textbox";
x.TextWrapping = TextWrapping.Wrap;
x.Height = 20;
x.Width = 100;
x.AcceptsReturn = true;
x.Margin = new Thickness(5, 10, 0, 0);
canvas1.Children.Add(x);
Canvas.SetLeft(x, 100);
Canvas.SetTop(x, 100);
}
private void AddQuestion_Click(object sender, RoutedEventArgs e)
{
TextBox x = new TextBox();
x.Name = "new_textbox";
x.TextWrapping = TextWrapping.Wrap;
x.Height = 20;
x.Width = 200;
x.AcceptsReturn = true;
x.Margin = new Thickness(5, 10, 0, 0);
canvas1.Children.Add(x);
Canvas.SetLeft(x, 140);
Canvas.SetTop(x, 140);
}
The Title position is the smaller Textbox and the question the bigger Textbox. A title can have any amount of questions it. So when I click 'Add question' I need it to appear below the last question Textbox and when I click add title I need it to appear below the last question but in a different position?
I deleted my old post as I figured out how to add the Textboxes.