Datagrid单元格的内容需要居中。设置textalignment属性。 但内容不集中。我错过了什么。
Style aStyle = new Style()
{
TargetType = typeof(TextBlock)
};
aStyle.Setters.Add(new Setter(TextBlock.TextAlignmentProperty,TextAlignment.Center));
DataGridTextColumn c1 = new DataGridTextColumn();
c1.Width = 20;
c1.Header = "Index";
c1.Binding = new Binding("Index");
c1.Width = 110;
c1.IsReadOnly = true;
c1.ElementStyle = aStyle;
aDataGrid.Columns.Add(c1);