How to right align text in a DataGrid column header in xaml?

前端 未结 2 1470
暖寄归人
暖寄归人 2021-02-19 02:37

I have a WPF DataGrid with a column header as follows:


     ...



        
相关标签:
2条回答
  • 2021-02-19 02:37

    H.B's answer is correct; just add one more line:

    <DataGridTextColumn.HeaderStyle>
        <Style TargetType="{x:Type DataGridColumnHeader}">
          <Setter Property="HorizontalAlignment" Value="Stretch"/>
          <Setter Property="HorizontalContentAlignment" Value="Right"/>
        </Style>
    </DataGridTextColumn.HeaderStyle>
    
    0 讨论(0)
  • 2021-02-19 02:59

    Set the HorizontalContentAlignment of the header using the HeaderStyle:

    <DataGridTemplateColumn.HeaderStyle>
        <Style TargetType="DataGridColumnHeader">
            <Setter Property="HorizontalContentAlignment" Value="Right"/>
        </Style>
    </DataGridTemplateColumn.HeaderStyle>
    
    0 讨论(0)
提交回复
热议问题