[C# WPF][DevExpress] band를 이용한 GridControl 의 Header 및 Cell (row) 모두 가운데 정렬하기
GridControl Header는 가운데 정렬을 했는데 아무리 해도 GridControl 안에 셀들이 가운데 정렬이 되지 않아서 애먹었는데
How to control text alignment for entire GridControl?
You have yet to view any tickets. Your search criteria do not match any tickets. A server error occurred while processing your request. Please try again at a later time.
supportcenter.devexpress.com
https://supportcenter.devexpress.com/ticket/details/t363573/how-to-align-content-in-gridcolumn-cells
How to align content in GridColumn cells
You have yet to view any tickets. Your search criteria do not match any tickets. A server error occurred while processing your request. Please try again at a later time.
supportcenter.devexpress.com
위 두 게시글을 참고해서 아래와 같이 적용하니 cell 안의 내용들이 가운데 정렬 되었다.
<dxg:GridColumn FieldName="2월">
<dxg:GridColumn.EditSettings>
<dxe:TextEditSettings HorizontalContentAlignment="Center"/>
</dxg:GridColumn.EditSettings>
</dxg:GridColumn>
하지만 언제까지나 저 코드를 반복할수는 없어서 하나로 묶고싶었다.
<UserControl.Resources>
<!-- 표 정렬 -->
<Style TargetType="{x:Type dxg:GridColumn}">
<Setter Property="HorizontalHeaderContentAlignment" Value="Center"/>
<Setter Property="EditSettings">
<Setter.Value>
<dxe:TextEditSettings HorizontalContentAlignment="Center"/>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type dxg:GridControlBand}">
<Setter Property="HorizontalHeaderContentAlignment" Value="Center">
</Setter>
</Style>
</UserControl.Resources>
<DockPanel>
<dxg:GridControl>
<dxg:GridControl.Bands>
<dxg:GridControlBand ...
<dxg:GridColumn ...
이렇게 작업하면 GridControl 표 전체의 내용이 가운데정렬된다.