Page 1 of 1

DataGrid Columns & Headers don't update after appearing

Posted: Tue Aug 06, 2019 7:52 am
by TaterJuice
I have a datagrid which needs to be built dynamically, so I placed an empty data grid in a page (with AutoGenerateColumns=False), then on page.Loaded, I add columns to the datagrid by dg.Columns.Add().
These new columns do not show up in the datagrid.

So I tried adding the datagrid columns in the page xaml, and I gave each column an x:Name attribute, so on page.Loaded I could change the headers, ie: dgTitleHeader.Header="Rank".
The column headers still do not update.

Re: DataGrid Columns & Headers don't update after appearing

Posted: Tue Aug 06, 2019 1:48 pm
by JS-Support @Userware
Thanks.

Could you please try setting the columns in the constructor if the page rather than the Loaded event ?

Also, can you please try the small showcase app that you get under Visual Stidio when you click File -> New Project -> CSHTML5 Showcase

It contains a sample DataGrid with custom columns.

Regards