我正在从字符串格式化列标题,例如背景属性:
var style = new Style(typeof(System.Windows.Controls.Primitives.DataGridColumnHeader));
style.Setters.Add(new Setter(DataGridColumnHeader.BackgroundProperty, new SolidColorBrush((Color)ColorConverter.ConvertFromString("Yellow"))));
但是我不知道如何将HorizontalContentAlignment设置为“ Center”。我想通过反思,但我不知道在这种情况下的确切用途。