xaml page
<DataGrid Grid.Row="2" x:Name="date" AutoGeneratingColumn="Date_AutoGeneratingColumn" AutoGenerateColumns="True" Margin="10"> <DataGrid.RowStyle> <Style TargetType="DataGridRow"> <Setter Property="Height" Value="40"/> <Setter Property="FontSize" Value="30"></Setter> </Style> </DataGrid.RowStyle> </DataGrid>
Add AutoGeneratingColumn event
private void Date_AutoGeneratingColumn(object sender, DataGridAutoGeneratingColumnEventArgs e) { var result = e.PropertyName; var p = (e.PropertyDescriptor as PropertyDescriptor).ComponentType.GetProperties().FirstOrDefault(x => x.Name == e.PropertyName); if (p != null) { var found = p.GetCustomAttribute<DisplayAttribute>(); if (found != null) result = found.Name; } e.Column.Header = result; }