QA@IT
«回答へ戻る

回答を投稿

以下みたいな感じでどうでしょうか?

<DataGrid.Columns>
  <DataGridTextColumn Header="Number" Binding="{Binding XPath=@Number}" Width="100">
    <DataGridTextColumn.ElementStyle>
      <Style TargetType="{x:Type TextBlock}" >
        <Setter Property="TextAlignment" Value="Center" />
      </Style>
    </DataGridTextColumn.ElementStyle>
  </DataGridTextColumn>
</DataGrid.Columns>

<DataGrid.ColumnHeaderStyle>
  <Style TargetType="DataGridColumnHeader">
    <Setter Property="HorizontalContentAlignment" Value="Center"/>
  </Style>
</DataGrid.ColumnHeaderStyle>
以下みたいな感じでどうでしょうか?

```xml
<DataGrid.Columns>
  <DataGridTextColumn Header="Number" Binding="{Binding XPath=@Number}" Width="100">
    <DataGridTextColumn.ElementStyle>
      <Style TargetType="{x:Type TextBlock}" >
        <Setter Property="TextAlignment" Value="Center" />
      </Style>
    </DataGridTextColumn.ElementStyle>
  </DataGridTextColumn>
</DataGrid.Columns>

<DataGrid.ColumnHeaderStyle>
  <Style TargetType="DataGridColumnHeader">
    <Setter Property="HorizontalContentAlignment" Value="Center"/>
  </Style>
</DataGrid.ColumnHeaderStyle>
```