private void DataGrid_AutoGeneratingColumn(object sender, DataGridAutoGeneratingColumnEventArgs e)
{
Style style = this.Resources["cellStyle"] as Style;
//Style cellStyle = new Style(typeof(DataGridCell)) { BasedOn = style };
e.Column.CellStyle = new Style(typeof(DataGridCell)) { BasedOn = style };
e.Column.CellStyle.Setters.Add(new Setter(DataGridCell.VerticalAlignmentProperty, VerticalAlignment.Center));
e.Column.CellStyle.Setters.Add(new Setter(DataGridCell.BackgroundProperty, new SolidColorBrush(Color.FromRgb(162, 201, 242))));
}
后台cs 设置DataGrid样式 new style
最新推荐文章于 2021-11-30 23:33:05 发布