I am trying to associate a DataGrid with a shared list in WPF.
The following code results in blank lines for each row of data in my list (i.e. if I have 5 rows, it shows 5 rows but does not show any data in the cells):
List<DataRow> DataBindingSource = GuestList.Where(row => (row.Field<long>("FK_GROUP_ID") == Int64.Parse(cmbGroup.SelectedValue.ToString())) && (row.Field<long>("FK_AGE_GROUP_ID") != (int)L_Age_Group.Child)) .ToList(); gvwAddultDetails.ItemsSource = DataBindingSource;
If I convert my list of objects to a DataTable , it works (shows data). For example:
List<DataRow> DataBindingSource = GuestList.Where(row => (row.Field<long>("FK_GROUP_ID") == Int64.Parse(cmbGroup.SelectedValue.ToString())) && (row.Field<long>("FK_AGE_GROUP_ID") != (int)L_Age_Group.Child)) .ToList(); gvwAdultDetails.ItemsSource = DataBindingSource.CopyToDataTable().DefaultView;
But if I had a List<DataRow> , how would I convert it to a DataTable ?
What is the best practice for binding a DataGrid to a "list" in WPF?
c # data-binding wpf
Shantanu gupta
source share