WPF- “LineSpacing” in a TextBlock

做~自己de王妃 提交于 2020-01-02 05:43:07

问题


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:

How can I manage to preserve said 'LineSpacing' without modifying the LineHeight before the first line?

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.

ANSWER

It seems that you can use LineStackingStrategy="MaxHeight" to avoid having leading on the first line. (Check answers below for full details).

P.S. Thanks to Mitch for the revelation :D


回答1:


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>

Produces



来源:https://stackoverflow.com/questions/23874453/wpf-linespacing-in-a-textblock

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!