如何从 WPF TextBlock 中删除额外的填充? [英] How to remove additional padding from a WPF TextBlock?
本文介绍了如何从 WPF TextBlock 中删除额外的填充?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
默认情况下,WPF TextBlock
似乎应用了额外的顶部和底部填充.我希望不是这样.
By default a WPF TextBlock
seems to have additional top and bottom padding applied. I wish this wasn't so.
我试过设置负填充,但有一个例外:
I've tried setting negative padding, but got an exception:
0,-10,0,0' 不是属性 'Padding' 的有效值.
我试过设置 LineHeight
属性,但没有明显效果.
I've tried setting the LineHeight
property, to no apparent effect.
这就是 TextBlock 在 Blend 中的样子.我用栗色标记了有问题的部分.
This is how the TextBlock looks in Blend. I've marked the problematic portion with maroon red.
推荐答案
一些研究和 HB 引导我正确答案,即设置以下属性:
Some research and H.B. guided me to the right answer, which is setting the following properties:
<TextBlock LineStackingStrategy="BlockLineHeight"
LineHeight="20"/> <!-- Or some other value you fancy. -->
这篇关于如何从 WPF TextBlock 中删除额外的填充?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文