How can i change the WPF DataGrid Column Header Text via code behind? i tried the code below but its not working.
this.sampleDataGrid.Columns[0].Header = "New Header";
this.sampleDataGrid.Refresh();
How can i change the WPF DataGrid Column Header Text via code behind? i tried the code below but its not working.
this.sampleDataGrid.Columns[0].Header = "New Header";
this.sampleDataGrid.Refresh();
If your DataGridColumn is a Template then you need to change its Template in code.
var template = new DataTemplate();
template.VisualTree = new FrameworkElementFactory(typeof(TextBlock));
template.VisualTree.SetValue(TextBlock.TextProperty, "New Header");
dataGrid.Columns[0].HeaderTemplate = template;