如何在WPF中设置可调整字体大小的文本块或标签? [英] How to set textblock or label with resizable font size in WPF?

查看:629
本文介绍了如何在WPF中设置可调整字体大小的文本块或标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在WPF中,如果我在网格中放置任何控件,如果我调整网格的大小,它会自动调整其中所有控件的大小,但是在label或textblock或任何其他文本元素中,所有控件的大小都会改变,但字体大小仍然保持不变一样,它不会改变.

In WPF, if i put any controls in grid, if i resize the grid, it automatically resizes all the controls in it.But in label or textblock or any other text elements, all the control sizes will change but font size remains same, it will not change.

如果必须根据网格大小更改字体,应该怎么办?

If font has to change as per grid size, What should be done?

推荐答案

您可以使用ViewBox来实现.它将根据控件的大小变换(而不是调整控件的大小)字体.

You can achieve this by using a ViewBox. It will transform (not resize) your font (well, the control) depending on the control size.

请参见在此处获取更多信息

Look at this here for more information;

<Viewbox Stretch="Uniform">
    <TextBlock Text="Test" />
</Viewbox>

这篇关于如何在WPF中设置可调整字体大小的文本块或标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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