How to change column header's background color when using WPF datagrid

后端 未结 6 524
遥遥无期
遥遥无期 2020-12-13 09:24

How to change column header\'s background color when using WPF datagrid? Need to modify xaml directly?

6条回答
  •  旧时难觅i
    2020-12-13 10:04

    Style style = new Style(typeof(System.Windows.Controls.Primitives
        .DataGridColumnHeader));
    style.Setters.Add(new Setter(ToolTipService.ToolTipProperty
        ,"Your tool tip here"));
    style.Setters.Add(new Setter { Property = BackgroundProperty, Value 
        = Brushes.Yellow });
    
    
    dgExcelSheet.Columns[1].HeaderStyle = style;
    

提交回复
热议问题