我有這些2類:PagedViewCollection基,不屬性
class EmpIDPayTypeSettings
{
public Guid OID { get; set; }
public Guid PayTypeOID { get; set; }
public int GroupTypeID { get; set; }
public Guid EmpOID { get; set; }
public int OrderBy { get; set; }
}
class DocRegHour
{
public Guid OID { get; set; }
public Guid DocumentOID { get; set; }
public Guid medarbejderOID { get; set; }
public Guid PaytypeOID { get; set; }
public string PayTypeInfo { get; set; }
public double Hours { get; set; }
public string Comment { get; set; }
public DateTime CreatedDate { get; set; }
public DateTime LastChangedDate { get; set; }
}
我有綁定到的DataGrid的ItemSource的DocRegHour
集合。 我希望他們按GroupTypeID
分組,因爲您可以看到兩個類共有PaytypeOID
。
我試着用Header = "Group"
製作一個無界限的摺疊列,並將GroupTypeID
設置爲每行中的文本。 然後我寫道:
var pcv = new PagedCollectionView(dataGridDayView.ItemsSource);
pcv.GroupDescriptions.Add(new PropertyGroupDescription("Group"));
dataGridDayView.ItemsSource = pcv;
雖然它不工作。任何幫助?
澄清。我有:
IEnumerable<DocRegHour> data;
IENumerable<EmpIDPayTypeSettings> userSettings;
var pcv = new PagedCollectionView(data);
dataGridDayView.ItemsSource = pcv;
這一點我通過GroupTypeID!這是一個不同的集合
但我不想要某種變異類。我需要很多次從行中提取數據。比如(SelectedItem as DocRecHour),我不能這樣做,用你的方法。另外,如果數據網格有動態列呢? – CasperT 2011-04-29 13:17:51
好吧,這是可以理解的。你有NavigationProperties嗎?如果是的話,你可以使用它們。 – LueTm 2011-04-29 13:24:42
對不起,這些是什麼?我無法在msdn上找到它們 – CasperT 2011-05-02 06:04:07