WPF TextBlock字体调整大小以填充网格中的可用空间 [英] WPF TextBlock font resize to fill available space in a Grid
问题描述
我有一些文本在运行时显示在文本块中。我想
的字体大小是最大的可以是填充
给定的区域。我认为我有正确的文本块设置autosize和
我试图增加字体大小,直到文本块大于
其父然后减少字体大小1.问题是我可以't
得到控制重绘/重新计算它的大小。
是一个更好的方法来做到这一点?或者有什么方法可以让我的方法工作? 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
这篇关于WPF TextBlock字体调整大小以填充网格中的可用空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
$ b $ p $ lt; code>< Grid> $>在$
< Viewbox>
< TextBlock TextWrapping =WrapText =Some Text/>
< / Viewbox>
< / Grid>
TextBlock
inside a ViewBox
: <Grid>
<Viewbox>
<TextBlock TextWrapping="Wrap" Text="Some Text" />
</Viewbox>
</Grid>