http://www.soaspx.com/dotnet/silverlight/silverlight_20110102_7027.html
设置居中还要额外的加一个
命名空间:xmlns:Primitives="clr-namespace:System.Windows.Controls.Primitives;assembly=System.Windows.Controls.Data"
再通过定义统一资源样式
<Style x:Key="DataGridHeaderStyle" TargetType="Primitives:DataGridColumnHeader">
<Setter Property="HorizontalContentAlignment" Value="Center"></Setter>
</Style>
<Style x:Key="DataGridCellStyle" TargetType="data:DataGridCell">
<Setter Property="HorizontalContentAlignment" Value="Center" ></Setter>
</Style>
然后在要居中的列引用这个样式如
CellStyle="{StaticResource DataGridCellStyle}"
HeaderStyle="{StaticResource DataGridHeaderStyle}"这个是列头
本文介绍如何在 Silverlight 的 DataGrid 控件中实现文本居中显示。通过添加特定的命名空间,并定义统一资源样式,可以轻松地将 DataGrid 的列头和单元格内容设置为水平居中。
49

被折叠的 条评论
为什么被折叠?



