I use WPF (C #). I use DataGrid. I want the first column is aligned with the center, the other columns are right-aligned.
I general have style:
<Style x:Key="TextInCellCenter" TargetType="{x:Type TextBlock}" >
<Setter Property="HorizontalAlignment" Value="Center"/>
</Style>
<Style TargetType="{x:Type DataGridCell}">
<Setter Property="HorizontalAlignment" Value="Right"/>
</Style>
DataGrids:
<DataGrid Name="DG1">
<DataGrid.Columns>
<DataGridTextColumn ElementStyle="{StaticResource TextInCellCenter}" Binding="{Binding Path=Name}" />
<DataGridTextColumn Binding="{Binding Path=Number}" />
<DataGridTextColumn Binding="{Binding Path=Number}" />
....
<DataGridTextColumn Binding="{Binding Path=Number}" />
<DataGridTextColumn Binding="{Binding Path=Number}" />
</DataGrid.Columns>
</DataGrid>
<DataGrid Name="DG2">
<DataGrid.Columns>
<DataGridTextColumn ElementStyle="{StaticResource TextInCellCenter}" Binding="{Binding Path=Name}" />
<DataGridTextColumn Binding="{Binding Path=Number}" />
<DataGridTextColumn Binding="{Binding Path=Number}" />
...
<DataGridTextColumn Binding="{Binding Path=Number}" />
<DataGridTextColumn Binding="{Binding Path=Number}" />
</DataGrid.Columns>
</DataGrid>
....
I have all the columns are right-aligned.
Please tell me, how do I change the first column had a center text-alignment?
p.s. How to do it in a rational way? I've got a lot of similar tables.