如何将动态创建的文本块的高度和宽度设置为自动?
TextBlock myTextBlock = new TextBlock() { Text = "Text Block", Width = 140, Height = 40, FontSize = 20 };
Run Code Online (Sandbox Code Playgroud) public void myTextBlock1_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
StackPanel mystack = new StackPanel() { Height = 100, Width = 200 };
TextBlock myTextBlock1 = new TextBlock()
{ Text = "Text Block", Width = 350, Height = 40, FontSize = 20,
VerticalAlignment = VerticalAlignment.Center,
TextAlignment = TextAlignment.Center,
HorizontalAlignment = HorizontalAlignment.Center, };
mystack.Children.Add(myTextBlock1);
}
for (int r = 0; r < m; r++)
{
TextBlock myTextBlockr = new TextBlock()
{ Text = "Text Block", Width = 350, Height = 40, FontSize = 20, …Run Code Online (Sandbox Code Playgroud)