2

我正在 WPF 中设计一些网格并希望显示与右侧对齐的数字,但是当我设置 Horizo​​ntalAlignment=Right 时,单元格本身不会使用所有可用宽度,因此边框会根据内容绘制一半。看附图。

在此处输入图像描述

代码是:

<Grid Width="620" Name="tblTaxBalance">
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="110"/>
        <ColumnDefinition Width="350"/>
        <ColumnDefinition Width="80" Style="{StaticResource CellRightAlign}"/>
        <ColumnDefinition Width="80" Style="{StaticResource CellRightAlign}"/>
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="Auto"/>
    </Grid.RowDefinitions>

    <!-- row 1 -->
    <Label Grid.RowSpan="2" Grid.Row="0" Style="{StaticResource TaxTableCellStyle}" BorderThickness="1">Тайлангийн төрөл</Label>
    <Label Grid.RowSpan="2" Grid.Row="0" Grid.Column="1" Style="{StaticResource TaxTableCellStyle}" BorderThickness="0,1,1,1">Татварын төрөл</Label>
    <Label Grid.ColumnSpan="2" Grid.Row="0" Grid.Column="2" Style="{StaticResource TaxTableCellStyle}" BorderThickness="0,1,1,1">Эцсийн үлдэгдэл /мян. төг/</Label>

    <!-- row 2 -->
    <Label Grid.RowSpan="2" Grid.Row="1" Grid.Column="2" Style="{StaticResource TaxTableCellStyle}" BorderThickness="0,0,1,1" HorizontalAlignment="Right">Дутуу</Label>
    <Label Grid.RowSpan="2" Grid.Row="1" Grid.Column="3" Style="{StaticResource TaxTableCellStyle}" BorderThickness="0,0,1,1">Илүү</Label>
</Grid>
4

1 回答 1

2

使用 Horizo​​ntalAlignment Stretch 并设置 FlowDirection RightToLeft

像那样:

<Label Grid.RowSpan="2" Grid.Row="1" Grid.Column="2" Style="{StaticResource TaxTableCellStyle}" BorderThickness="0,0,1,1" HorizontalAlignment="Stretch" FlowDirection="RightToLeft">Дутуу</Label>
于 2013-08-22T11:04:13.060 回答