Warm tip: This article is reproduced from stackoverflow.com, please click
uwp uwp-xaml

How to remove text block's padding in uwp?

发布于 2020-05-09 19:23:06

Recently I found that uwp render TextBlock with vertically margin in default.

For example, I wrap a TextBlock in a Border. The red rectangle maybe the safe space redered by TextBlock.

On Android, we can set

android:includeFontPadding="false"

So how to remove the red rectangle space on uwp?

enter image description here

Questioner
Vincent
Viewed
31
Vincent 2020-02-26 14:02

Finally I worked out a solution: Set

<TextBlock LineStackingStrategy="BlockLineHeight"
           LineHeight="44"/>

Refer to How to remove additional padding from a WPF TextBlock?