TextBlock text doesn't wrap when placed inside a ViewBox
Just set a width on the TextBlock
.
<Viewbox Width="500">
<TextBlock Width="100" TextWrapping="Wrap">This is the text that's long and on two lines.</TextBlock>
</Viewbox>
So the ViewBox
will zoom in/out its entire contents. If you don't restrict its contents by either setting a width on the TextBlock
, the ViewBox
will give it infinite space to expand into. You can also add a root Grid
with a width and height within the ViewBox
and lay your elements out in that, then the whole lot will get zoomed according to the width of the ViewBox
.
In the image, the width of the TextBlock
100 is zoomed to be the width of the ViewBox
which is 500. So to get the wrapping you want, just tweak the TextBlock
width until it looks nice.
(Obviously it should say three lines but I'm not re-uploading just for that)