代码之家  ›  专栏  ›  技术社区  ›  Joe White

减小文本块/流程文档中的行距

  •  42
  • Joe White  · 技术社区  · 15 年前

    有些字体在字符的上方和下方都有大量的空白。有没有一种方法可以纠正这种情况,并在wpf中(在文本块或流文档中)收紧换行段落行之间的间距?有点像两行之间的负空白?

    有一个 LineHeight 属性对 Paragraph TextBlock 但它似乎只让你 增加 间距——如果您将其设置为比默认值小的值,它将被忽略。

    3 回复  |  直到 10 年前
        1
  •  83
  •   Strigoides MrElmar    11 年前

    设置 LineHeight 像以前一样,但是改变 LineStackingStrategy BlockLineHeight

        2
  •  3
  •   johnildergleidisson    10 年前

    举例说明@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>
    
        3
  •  -1
  •   Community CDub    8 年前

    看到这个 question .

    有几种不同的方法来固定高度。为我工作的是 this 它将边距设置为0。