I am using WPF Data-grid with auto-generated columns. I am assigning data-table with one column but no rows as Items-source.
public DataTable GetInitData()
{
empDS = new DataSet();
empTbl = new DataTable();
empDS.Tables.Add(empTbl);
dc = new DataColumn("Test");
empDS.Tables[0].Columns.Add(dc);
empDS.AcceptChanges();
return empDS.Tables[0];
}
and I call the method above in the constructor.
public MainWindow()
{
this.InitializeComponent();
this.grdEmp.ItemsSource = this.GetInitData().DefaultView;
}
Screen-shot:
Now when I press F5 and run the code... the Data-grid doesn't show any column. Please guide me, why it is not showing any column. If you need any other information do let me know.
Regards, Priyank