How to grow/shrink a TextBlock (Font Size) to the available space in WPF?

The WPF Viewbox control will grow / shrink its contents to the available space:

http://www.wpftutorial.net/ViewBox.html

Just place your TextBlock within a ViewBox:

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

Of course, your Viewbox is typically scaled by its container, but hopefully you get the idea!

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)