1

我期望网格中同一行上的两种不同字体样式在网格行的底部对齐,但如您所见,它没有发生!

有人看到我需要改变什么吗?

干杯,
绿柱石

问题

在此处输入图像描述

网格

<Grid ShowGridLines="True">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>

        <Label Grid.Column="0" Grid.Row="0" Style="{StaticResource SubjectStyle}" .../>
        ...
        <TextBlock Grid.Column="2" Grid.Row="0" Style="{StaticResource DisplayNameStyle}" .../>
        ...
</Grid>

主题风格

<Style x:Key="SubjectStyle" TargetType="{x:Type Label}">
    <Setter Property="FontWeight" Value="Bold" />
    <Setter Property="FontSize" Value="10" />
    <Setter Property="HorizontalAlignment" Value="Left" />
    <Setter Property="VerticalContentAlignment" Value="Bottom" />
    <Setter Property="VerticalAlignment" Value="Bottom" />
    <Setter Property="Width" Value="75" />
</Style>

显示名称样式

<Style x:Key="DisplayNameStyle" TargetType="{x:Type TextBlock}">
    <Setter Property="FontSize" Value="16" />
    <Setter Property="HorizontalAlignment" Value="Left" />
    <Setter Property="VerticalAlignment" Value="Bottom" />
    <Setter Property="MinWidth" Value="75" />
</Style>
4

2 回答 2

2

Label默认Padding值为 5。TextBlock's默认值为 0。只需为样式中Padding的属性添加一个 setter 。Padding

于 2012-10-14T22:45:45.627 回答
1

在运行时在 Chrome 中启动它,然后按 F12 来检查元素。可能有一些边距或其他影响标签的问题不会影响您的文本块。

另外:为什么是标签,而不是两者的文本块?

最坏的情况是,在其中一个或另一个中添加一个边距,以确保它们排列整齐并跨浏览器进行验证。

于 2012-10-14T22:41:19.600 回答