I have a simple data structure class:
public class Client {
public String name {set; get;}
public String claim_number {set; get;}
}
Which I am feeding into a DataGrid:
this.data_grid_clients.ItemSource = this.clients;
I would like to change the column headings. Ie: claim_number to “Claim Number”. I know this can be done when you manually create the columns by doing something like:
this.data_grid_clients.Columns[0].Header = "Claim Number"
However, the Columns property is empty when auto-generating the columns. Is there a way to rename the columns, or do I have to manually generate the columns?
You can use DisplayNameAttribute and update some part of your code to achieve what you want.
The first thing you have to do is, adding a
[DisplayName("")]to properties in the Client class.The update you xaml code, add an event handler to AutoGenerationColumn event.
Finally, add a method to the code-behind.