出色地,
我textblock
在 c# 中以编程方式创建。但它没有显示在应用程序中。怎么了 ?
这是我更新的 C# 代码:
double left = 0, top = 15, right = 0, bottom = 0;
double left1 = 0, top1 = 12, right1 = 0, bottom1 = 12;
TextBlock fileName = new TextBlock();
fileName.Margin = new Thickness(left, top, right, bottom);
fileName.FontSize = 30;
fileName.Foreground = new SolidColorBrush(Colors.White);
fileName.TextAlignment = TextAlignment.Center;
fileName.Text = "hello";
StackPanel content = new StackPanel();
content.Margin = new Thickness(left1, top1, right1, bottom1);
content.SetValue(Grid.RowProperty, 0);
content.Children.Add(fileName);;