我需要將WPF DataGrid Column Header
文本對齊中心。我創建了一個樣式,並使用下面的HeaderStyle
屬性進行附加。將DataGrid列標題對齊中心
風格
<Window.Resources>
<Style x:Key="CenterGridHeaderStyle" TargetType="DataGridColumnHeader">
<Setter Property="HorizontalContentAlignment" Value="Center"/>
</Style>
</Window.Resources>
列
<DataGridTextColumn
Binding="{Binding Path=Name}" Header="Name" IsReadOnly="True"
HeaderStyle="{DynamicResource CenterGridHeaderStyle}"/>
但這不是對齊列標題文本到中心。我怎樣才能做到這一點 ?
你可以找到答案: http://stackoverflow.com/questions/7943729/how-to-set-style-for-datagrid-header-in-wpf –
嘗試這樣的: HTTP ://stackoverflow.com/questions/7943729/how-to-set-style-for-datagrid-header-in-wpf –