如何获取分组列表视图中的第一个可见组键

时间:2016-06-07 07:29:35

标签: wpf listview grouping

我有一个ListView,它按itemsource中项目的datetime字段分组。我想让顶部项目的组密钥可见。此外,我想在新项目滚动到列表视图的顶部时立即获取更改的组密钥。我怎样才能实现它?

代码:

#disablingDiv {
    /* snip */
    position: fixed; /* not absolute */
    /* snip */
}

的Xaml:

public class ClassA
{
    public DateTime DateTimePropertyOfClassA { get; set; }
}

public class MyVM
{
    public MyVM()
    {
        //return a grouped collection:
        Grouped = from x in CollectionOfClassA group x by x.DateTimePropertyOfClassA into grp orderby grp.Key select grp;
    }

    public IList<ClassA> CollectionOfClassA { get; set; } = new List<ClassA>()
    {
            new ClassA(){ DateTimePropertyOfClassA = DateTime.Parse("2016-01-01")},
            new ClassA(){ DateTimePropertyOfClassA = DateTime.Parse("2016-03-01")},
            new ClassA(){ DateTimePropertyOfClassA = DateTime.Parse("2016-03-01")},
            new ClassA(){ DateTimePropertyOfClassA = DateTime.Parse("2016-03-01")},
            new ClassA(){ DateTimePropertyOfClassA = DateTime.Parse("2016-03-01")},
            new ClassA(){ DateTimePropertyOfClassA =DateTime.Parse("2016-06-01")}
        };

        public IEnumerable<object> Grouped { get; }
}

0 个答案:

没有答案