45

某些字体在字符上方和下方有大量空白。有没有办法纠正这个问题,并收紧 WPF 中自动换行段落的行之间的空间(在 TextBlock 或 FlowDocument 中)?有点像行之间的负边距?

and上有一个LineHeight属性,但它似乎只能让你增加间距——如果你将它设置为比默认值更小的值,它就会被忽略。ParagraphTextBlock

4

3 回答 3

85

之前设置LineHeightlike,但更改LineStackingStrategyBlockLineHeight

于 2009-09-17T20:14:08.093 回答
4

举例说明@Joel的答案(5年后仍然非常有用:P)

    <StackPanel VerticalAlignment="Center">
        <Button Width="137" Height="47.96">
            <TextBlock Text="This is a very long text that gets cut because it is so long" TextWrapping="Wrap"/>
        </Button>
        <Button Width="137" Height="47.96">
            <TextBlock Text="This is a very long text that doesn't cut thanks to @Joel" TextWrapping="Wrap" 
                LineStackingStrategy="BlockLineHeight" LineHeight="13"/>
        </Button>
    </StackPanel>
于 2014-08-08T15:09:37.240 回答
0

看到这个问题

有几种不同的方法来固定高度。对我有用的是这个,它将边距设置为 0。

于 2009-08-10T12:24:29.227 回答