tags:

views:

57

answers:

1

I have a textblock which needs to

  1. show text in the maximum font size possible within the given space (less characters bigger letters and vice-versa)
  2. wrap the text within the given space.

I tried using a textbox inside a viewbox like below but the text-wrapping doesn't work if i don't specify the textblock width and height. If i do specify the width and height to the same size as the viewbox, obviously zooming doesn't happen.

<Viewbox Stretch="Fill" Width="100" Height="100">
<TextBlock TextWrapping="Wrap"/>
</Viewbox>

Is there any other way to acheive this? Or should i think about writing an algorithm to increase font size manually based on the amount of text? Any help is appreciated.

A: 

The good thing about WPF is that the elements are vector based not raster graphics, so you do not need to change the fontsize.

A viewbox as suggested in this should do the trick

benPearce