简体   繁体   English

WPF- TextBlock中的“LineSpacing”

[英]WPF- “LineSpacing” in a TextBlock

I have a TextBlock I would like to pass a property of ' LineSpacing '. 我有一个TextBlock我想传递' LineSpacing '的属性。 The thing with using " LineHeight " with LineStackingStrategy="BlockLineHeight" is that it also applies the LineHeight to the segment before the first line: 使用“ 线高 ”与LineStackingStrategy =“BlockLineHeight”的事情是,它也适用该线高到第一行之前的部分:

TextblockEx http://i61.tinypic.com/2a5y9mw.jpg TextblockEx http://i61.tinypic.com/2a5y9mw.jpg

How can I manage to preserve said ' LineSpacing ' without modifying the LineHeight before the first line? 如何管理维护说:“LineSpacing”没有在第一行之前修改线高

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 . 我可能会做的一件事是将FlowDocumentParagraph中的每一行分开,因为Paragraph有一个属性Spacing Before LineSpacing 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. 看来你可以使用LineStackingStrategy =“MaxHeight”来避免在第一行上领先。 (Check answers below for full details). (查看下面的答案以获取详细信息)。

PS Thanks to Mitch for the revelation :D PS感谢Mitch的启示 :D

It seems that you can use LineStackingStrategy="MaxHeight" to avoid having leading on the first line: 您似乎可以使用LineStackingStrategy="MaxHeight"来避免在第一行上占优势:

<TextBlock LineStackingStrategy="MaxHeight" TextWrapping="Wrap" LineHeight="50">Lorem...</TextBlock>

Produces 产生

最大高度

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM