对于列值居中,更改列的EditSettings,设置对应的EditSettings的HorizontalContentAlignment="Center"即可。
示例代码如下:
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid" xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors" x:Class="WpfApplication18.MainWindow"
Title="MainWindow" Height="350" Width="525">
<Window.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>
</Window.Resources>
<Grid>
<dxg:GridControl ItemsSource="{Binding students}">
<dxg:GridControl.Columns>
<dxg:GridColumn FieldName="id" />
<dxg:GridColumn FieldName="name" />
</dxg:GridControl.Columns>
<dxg:GridControl.View>
<dxg:TableView/>
</dxg:GridControl.View>
</dxg:GridControl>
</Grid>
</Window>
|
效果如下: