我在.Net中有一個項目,我似乎無法獲取textblock中的文本以包裝。TextBox不包裹
titleBlock = new TextBlock();
titleBlock.FontSize = 30;
titleBlock.TextWrapping = System.Windows.TextWrapping.Wrap;
titleBlock.Text = "jkhkjhkjh kjhkjhkjhkjhk jhkjh kjh kjh kjh kjh kjh kjh jkh k";
titleBlock.Padding = new System.Windows.Thickness(20);
titleBlock.Foreground = Brushes.White;
titleLabel.Content = titleBlock;
titleLabel.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center;
titleLabel.VerticalContentAlignment =System.Windows.VerticalAlignment.Center;
titleLabel.Margin = new System.Windows.Thickness(20, 30, 20, 20);
canvas.Children.Add(titleLabel);
目前的文本居中。不過,我似乎無法讓文字換行。如果我的文本太多,它只是在屏幕上而不是在屏幕上顯示。
標題和描述不匹配。它是'TextBox'還是'TextBlock'? – Sach
而且它是WPF還是WinForms? – Sach
@Sach我認爲這是WPF – lost9123193