简体   繁体   中英

Change FontSize to fit TextBlock

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

Try putting the text inside the control into a Viewbox :

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

Source

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM