【发布时间】:2016-04-12 05:36:35
【问题描述】:
是否可以在 wpf 中按对象属性进行分组? 例如:
public class Ausgabe
{
public int Id { get; set; }
public Mitarbeiter Mitarbeiter { get; set; }
public Ausgabestatus Status { get; set; }
public Bestellung Bestellung { get; set; }
}
public class Mitarbeiter
{
public int Id { get; set; }
public String Vorname { get; set; }
public String Nachname { get; set; }
public String FullName
{
get { return Nachname + " " + Vorname; }
}
}
我的数据网格的ItemsSource 包含一个List<Ausgabe>,我想按Mitarbeiter.FullName 分组
CollectionView cv = (CollectionView)CollectionViewSource.GetDefaultView(dgErfasst.ItemsSource);
cv.GroupDescriptions.Clear();
PropertyGroupDescription pgd = new PropertyGroupDescription("Mitarbeiter.Vorname");
cv.GroupDescriptions.Add(pgd);
这似乎不起作用。有没有办法实现这种分组?
【问题讨论】:
标签: c# wpf properties grouping