0

我的 XAML 中有以下内容:

<Grid x:Name="LayoutRoot" Background="White">
    <Grid.RowDefinitions>
        <RowDefinition Height="20"/>
        <RowDefinition Height="7"/>
        <RowDefinition Height="57"/>
    </Grid.RowDefinitions>

    <TextBlock Grid.Row="0" FontSize="18">Title Text</TextBlock>

    <Rectangle Grid.Row="1" Margin="0,2" Height="3" HorizontalAlignment="Stretch" Fill="#ff000000"/>

    <Border Grid.Row="2" Margin="0" Padding="0" BorderBrush="Black" BorderThickness="1">
        <TextBlock Margin="0" Padding="0" FontSize="55">123</TextBlock>
    </Border>
</Grid>

问题是底部TextBlock中的文字上方有一个空格(大约10px)。我似乎只能通过使用更小的字体来摆脱这个空间。

有谁知道为什么会出现这个空间,以及我能做些什么?

谢谢你。

4

1 回答 1

1

我相信这是因为 TextBlock 上的默认 VerticalAlignment 是 Stretch。尝试将其设置为中心:

<TextBlock Margin="0" Padding="0" FontSize="55" VerticalAlignment="Center">123</TextBlock>

如果你真的需要把它推高,你可以添加一个负的上边距。

于 2009-12-18T16:55:18.570 回答