How to make a cell for full width when aligning left or right in a WPF grid

I am designing some grid in WPF and want to display the numbers aligned to the right, but when I set HorizontalAlignment = Right, the cell itself does not use the entire available width, so the border is half-colored depending on the content. See attached picture.

enter image description here

The code:

<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> 
+2
c # wpf datagrid grid-layout
Aug 22 '13 at
source share
1 answer

Use HorizontalAlignment Stretch and set FlowDirection RightToLeft

Like:

 <Label Grid.RowSpan="2" Grid.Row="1" Grid.Column="2" Style="{StaticResource TaxTableCellStyle}" BorderThickness="0,0,1,1" HorizontalAlignment="Stretch" FlowDirection="RightToLeft"></Label> 
+2
Aug 22 '13 at 11:04 on
source share



All Articles