WPF-“行间距"在文本块中 [英] WPF- "LineSpacing" in a TextBlock
问题描述
我有一个 TextBlock,我想传递LineSpacing"的属性.使用LineHeight"的事情与 LineStackingStrategy="BlockLineHeight" 相同的是,它还将 LineHeight 应用于第一行之前的线段:
I have a TextBlock I would like to pass a property of 'LineSpacing'. The thing with using "LineHeight" with LineStackingStrategy="BlockLineHeight" is that it also applies the LineHeight to the segment before the first line:
如何在不修改第一行之前的 LineHeight 的情况下设法保留所说的LineSpacing"?
How can I manage to preserve said 'LineSpacing' without modifying the LineHeight before the first line?
我认为可能可行的一件事是将 FlowDocument 的 Paragraph 中的每一行分开,因为 Paragraph 有一个属性 行前间距和行后间距.
One thing I though might work is to separate each line in a Paragraph of a FlowDocument, since the Paragraph has a property Spacing Before Line and Spacing After Line.
任何帮助将不胜感激.提前致谢.
Any help would be truly appreciated. Thanks in advance.
答案
似乎您可以使用 LineStackingStrategy="MaxHeight" 来避免在第一行出现前导.(查看下面的答案以了解详细信息).
It seems that you can use LineStackingStrategy="MaxHeight" to avoid having leading on the first line. (Check answers below for full details).
P.S.感谢米奇的启示 :D
推荐答案
看来你可以使用 LineStackingStrategy="MaxHeight"
来避免第一行有前导:
It seems that you can use LineStackingStrategy="MaxHeight"
to avoid having leading on the first line:
<TextBlock LineStackingStrategy="MaxHeight" TextWrapping="Wrap" LineHeight="50">Lorem...</TextBlock>
生产
这篇关于WPF-“行间距"在文本块中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!