Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Silverlight DataGrid Header Horizontal Alignment

I want to change the alignment of a header on a datagrid in Silverlight, and I can't seem to figure out how to do it. Here's what I have so far:

  <data:DataGridTextColumn Header="#" 
                            IsReadOnly="True"
                            ElementStyle="{StaticResource CenterAlignStyle}" 
                            Binding="{Binding OutlineNumber, Mode=OneWay}" >
    <data:DataGridTextColumn.HeaderStyle>
      <Style TargetType="prim:DataGridColumnHeader">
        <Setter Property="HorizontalAlignment" Value="Center"/>
      </Style>
    </data:DataGridTextColumn.HeaderStyle>
  </data:DataGridTextColumn>

No matter what I try, I can't seem to change the default alignment, which appears to be "left."

like image 369
Brandon Montgomery Avatar asked Mar 11 '10 16:03

Brandon Montgomery


1 Answers

You were really close, its:-

<Setter Property="HorizontalContentAlignment" Value="Center"/>
like image 199
AnthonyWJones Avatar answered Oct 13 '22 05:10

AnthonyWJones