我有以下数据结构:
public class TimeData
{
public Employee Employee { get; set; }
public IList<WorkTime> WorkTimes { get; set; }
}
视图模型:
public ObservableCollection<TimeData> TimeDatas { get; set; }
在我的数据网格中,我想显示所有工作时间。按员工分组。像这样:
日期 | 小时 | 时间码
乔恩·多伊
19 年 12 月 3 日 | 8 | 433
19 年 3 月 13 日 | 8 | 433
19 年 3 月 14 日 | 5 | 546
迈克·穆斯特
19 年 12 月 3 日 | 4 | 653
19 年 3 月 13 日 | 3 | 433
19 年 3 月 14 日 | 9 | 546
public class Employee
{
public string FirstName { get; set; }
public string LastName { get; set; }
}
public class WorkTime
{
public DateTime Date { get; set; }
public double Hours { get; set; }
public string TimeCode { get; set; }
}
我已经尝试过以下代码:
ListCollectionView collectionView = new ListCollectionView(this.viewModel.TimeDatas);
collectionView.GroupDescriptions.Add(new PropertyGroupDescription("Employee"));
this.grdTimeData.ItemsSource = collectionView;
这按员工分组,但不显示 WorkTimes 列表:
在网格行中,我只需要 WorkTimes,Employee 仅用于分组。
holdtom
相关分类