wpf 如何更改 TextBlock 中的行距

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16510420/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 08:46:29  来源:igfitidea点击:

How to change line spacing in TextBlock

wpf

提问by user1205398

I am using WPF, there is a TextBlock in my UserControl. The Text is very long, so I wrap it with TextWrapping = Wrap. The question is, how can I change the line spacing?

我正在使用 WPF,我的 UserControl 中有一个 TextBlock。文本很长,所以我用 TextWrapping = Wrap 包裹它。问题是,如何更改行距?

The code is something like:

代码是这样的:

<TextBlock Text="abcdefghijklmn" TextWrapping="Wrap"/>

The output is like:

输出是这样的:

abcdefghijk
lmn

What I want is:

我想要的是:

abcdefghijk
<--increase this line spacing-->
lmn

Great Thanks.

万分感谢。

回答by Phonix

Use LineHeighttogether with LineStackingStrategy="BlockLineHeight"

使用LineHeight连同LineStackingStrategy="BlockLineHeight"

Like

喜欢

<TextBlock Text="abcdefghijklmn" TextWrapping="Wrap" LineStackingStrategy="BlockLineHeight" LineHeight="30"/>

(credz Mixer for the BlockLineHeight addition)

(用于 BlockLineHeight 添加的 credz 混合器)