Change FontSize to fit TextBlock

允我心安 提交于 2020-01-12 03:28:27

问题


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


回答1:


Try putting the text inside the control into a Viewbox:

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

Source



来源:https://stackoverflow.com/questions/18765452/change-fontsize-to-fit-textblock

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!