I have a TextBox
and a Label. After clicking a button, I execute the following code:
label1.Content = textbox1.Text;
My question is, how do I enable text wrapping of the label? There may be too much text to display on one line, and I want it to automatically wrap to multiple lines if that is the case.
Best Answer
The
Label
control doesn't directly support text wrapping in WPF. You should use aTextBlock
instead. (Of course, you can place theTextBlock
inside of aLabel
control, if you wish.)Sample code: