I creating TabItems dynamically. Inside TabItem I want to add TextBox.
How can I set up position of TextBox?
GenerateTabControlModel gtcm = new GenerateTabControlModel();
for (int x = 0; x <= gtcm.getTabNumber();x++)
{
TabItem tab = new TabItem();
tab.Header = x.ToString();
tab.Width = 30;
tab.Height = 20;
string sometext = "tab number: " + x.ToString();
TextBox tb = new TextBox();
tb.Text = sometext;
tb.Height = 25;
tb.Width = 120;
tab.Content = tb;
TCDynamo.Items.Add(tab);
}
FrameworkElementhasMargin. Though consider to use dynamic layouting (Marginis still used in it, but it's not something likeMargin = "500,300,20,10), then you need a proper parent container (Grid + column/row definitions, StackPanel, WrapPanel, etc.) and utilizing alignment properties:VerticalAlignmentandHorizontalAlignment(e.g. centering).