如何获取多层次结构与CollectionViewSource绑定到语义缩放在Windows 8.1(

2019-11-03 07:33发布

我有一个Windows应用程序8.1中,我试图达到3级层次与CollectionViewSource,然后将它绑定到我的语义缩放

我的模型类看起来如下

class Transaction
{
    string id {get; set;}
    string name {get; set;}
    DateTimeOffset date {get; set;
}

这个模型的样本值可以是如下

[1, Food, 31/08/2014]
[2, Movie, 15/08/2014]
[3, Medicine, 20/07/2014]
[4, GameConsole, 02/07/2014]
[5, MobileBill, 18/06/2014]
[4, Tv, 06/06/2014]

我想在我的语义缩放,使得显示此数据

  1. 我ZoomedOutView是显示像八月,七月和六月个月的GridView。
  2. 在我ZoomedInView数据由日期分组

要做到这一点我必须建立在我的CollectionViewSource这3个级别

  1. 日期
  2. 单笔交易

用于上述层次结构的一例数据如下所示

August (Appears in ZoomedOutView only)
    August 31
        Transaction 1
        Transaction 2
    August 15
        Transaction 3
        Transaction 4
    August 1
        Transaction 5
        Transaction 6

July (Appears in ZoomedOutView only)
    July 20
        Transaction 7
        Transaction 8
    July 2
        Transaction 9
        Transaction 10

June (Appears in ZoomedOutView only)
    June 10
        Transaction 11
        Transaction 12

我的语义缩小视图将有

August
July
June

我的语义缩放ZoomedInView应该有

August 31
    Transaction 1
    Transaction 2
August 15
    Transaction 3
    Transaction 4
August 1
    Transaction 5
    Transaction 6
July 20
    Transaction 7
    Transaction 8
July 2
    Transaction 9
    Transaction 10
June 10
    Transaction 11
    Transaction 12

我想我的组列表到CollectionViewSource如下

List<Transaction> response = GetTransactions();
var TransactionCollectionViewSource = new CollectionViewSource();
TransactionCollectionViewSource.Source = response.ToGroups(x => x, x => x.date.Month);
TransactionCollectionViewSource.IsSourceGrouped = true;

我有GROUPBY一个月,现在怎么办我组到这个日子来着? 我应该有2 CollectionViewSource? 或者是有可能只用一个CollectionViewSource来实现这一目标。 我很困惑。

我会很高兴,如果有人能在正确的方向指向我。 提前致谢。

Answer 1:

SemanticZoom: http://msdn.microsoft.com/en-us/library/windows/apps/hh465319.aspx

尝试这个:

private void Zoom_ViewChangeStarted(object sender, SemanticZoomViewChangedEventArgs e)
{
    if (!e.IsSourceZoomedInView)
    {
        e.DestinationItem.Item = _selectedHubSection;
    }
}

祝您好运!



文章来源: How to obtain Multi-level hierarchy with CollectionViewSource to bind to Semantic Zoom in Windows 8.1