TextBlock wrapping of text in Silverlight XAML file
TextBlock wrapping of text in Silverlight XAML file.
开发者_如何学编程I have a wierd and annoying problem. I have a textblock that is inside a stackpanel that is Oriented horizontal. It would be nice if I could have the textblock appear in multiple lines nicely wrapped. How could I do that?
to wrap text, you set the property TextWrapping to Wrap:
<TextBlock TextWrapping="Wrap"/>
MSDN doc is here
By default StackPanels do not limit the size of their contents in the direction of Orientation. That is the direction they keep on growing.
You mention you have it Orientation = Horizontal, so that will not constrain the width of a TextBox within it.
If you want text wrapping: you either need to use a grid for the container (which will constrain it's children) or set a fixed width on the TextBox.
精彩评论