更改 FontSize 以适合 TextBlock [英] Change FontSize to fit TextBlock

查看:27
本文介绍了更改 FontSize 以适合 TextBlock的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发 Windows 8 Store 应用程序,我们知道显示尺寸非常不同,所以所有元素都有可伸缩设置,因此如果显示小元素(图片、图表等)较小,如果显示大- 更大.

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.

除了 TextBlocks(标签)外,其他一切都完美无缺:

All works perfectly except TextBlocks (labels):

TextBlock 元素本身也被拉伸,但 FontSize 保持不变,我怎么注意到没有改变字体大小以适合 TextBlock 的属性.

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.

有没有办法改变 TextBlock 的 FontSize 以适应容器?示例非常感谢

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

推荐答案

尝试将控件内的文本放入Viewbox:

Try putting the text inside the control into a Viewbox:

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

来源

这篇关于更改 FontSize 以适合 TextBlock的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆