This is my Class definition.
public class Customer {
[Display(Name="Customer ID")]
public int ID { get; set; }
[Display(Name="Customer Name")]
public string CusName { get; set; }
}
This is my XAML code
<DataGrid Name="DataGrid" />
And this is data binding
public Test() {
InitializeComponent();
List<Customer> cus = new List<Customer>();
cus.Add(new Customer() { ID = 1, CusName = "Jackson" });
cus.Add(new Customer() { ID = 2, CusName = "Micheal" });
cus.Add(new Customer() { ID = 3, CusName = "Jackson" });
DataGrid.ItemsSource = cus;
}
This is the result:
The DataGrid header columns diplay the ID,CusName, they are Customer's field name.
How to make DataGrid header column display Customer ID, Customer Name instead of ID, CusNumber ? They are in [Display] attribute