12

I'm developing Windows 8 Store Application, we know that display sizes are very different, so all the elements have stretchable settings, so that if display is small elements (pictures, charts etc. ) are smaller, if display is big - bigger.

All works perfectly except TextBlocks (labels):

TextBlock element itself also is being stretched, but the FontSize remains the same, how i noticed there is no property to change font size to fit TextBlock.

Is there a way to change FontSize of the TextBlock to fit the container? Examples are wery appreciated

Farhan Ghumra
  • 15,180
  • 6
  • 50
  • 115
Developer
  • 4,158
  • 5
  • 34
  • 66
  • Possible duplicate of [How to grow/shrink a TextBlock (Font Size) to the available space in WPF?](http://stackoverflow.com/questions/4794355/how-to-grow-shrink-a-textblock-font-size-to-the-available-space-in-wpf) – Breeze Oct 05 '15 at 14:48

1 Answers1

20

Try putting the text inside the control into a Viewbox:

<Viewbox Stretch="Uniform" Width="50" Height="50">
    <TextBlock Text="Test" />
</Viewbox>

Source

Community
  • 1
  • 1
Farhan Ghumra
  • 15,180
  • 6
  • 50
  • 115