I have some text that is displayed at run time in a textblock. I want the font size to be the biggest it can be to fill the area that is given. I think I have the textblock setup correctly to "autosize" and I try to increase the font size till the textblock is bigger than than its parent then decrease the font size by 1. The problem is I can't get the control to redraw/recompute its size.
Is the a better way to do that? Or is there a way I can make my method work?
Wrap the TextBlock
inside a ViewBox
:
<Grid> <Viewbox> <TextBlock TextWrapping="Wrap" Text="Some Text" /> </Viewbox> </Grid>
I had the same problem. You can use this to resize the fontsize of the textblock to fill the area when it has overflow.
<Viewbox StretchDirection="DownOnly" Stretch="Uniform"> <TextBlock Text="{Binding Path=Title}" HorizontalAlignment="Center"/> </Viewbox>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With