如何使用 CollectionViewSource 获取多级层次结构以绑定到 Windows 8.1 中的语义缩放 [英] How to obtain Multi-level hierarchy with CollectionViewSource to bind to Semantic Zoom in Windows 8.1

查看:17
本文介绍了如何使用 CollectionViewSource 获取多级层次结构以绑定到 Windows 8.1 中的语义缩放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Windows 8.1 应用程序,我试图在其中使用 CollectionViewSource 实现 3 级层次结构,然后将其绑定到我的语义缩放

I have a Windows 8.1 Application in which I am trying to achieve 3 levels of Hierarchy with CollectionViewSource and then Bind it to my Semantic Zoom

我的模型类如下

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

该模型的样本值可能如下

Sample value of this model could be as follows

[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]

我想在我的语义缩放中显示这些数据,以便

I want to display this data in my Semantic Zoom such that

  1. 我的 ZoomedOutView 是一个 GridView,它显示八月、七月和六月等月份.
  2. 在我的 ZoomedInView 中,数据按日期分组

为了实现这一点,我必须在我的 CollectionViewSource 中创建这 3 个级别

To achieve this I have to create these 3 levels in my CollectionViewSource

  1. 日期
  2. 个人交易

下面显示了上述层次结构的示例数据

An example data for the above hierarchy is shown below

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

我的语义缩小视图将具有

My Semantic Zoomed Out View will have

August
July
June

我的语义缩放 ZoomedInView 应该有

My Semantic Zoom ZoomedInView should have

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 中,如下所示

I am trying to group my List into CollectionViewSource as follows

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 来实现这一点.我很困惑.

I have got groupby month, now how do I group this into days again? Should I have 2 CollectionViewSource? Or is it possible to achieve this with just one CollectionViewSource. I am confused.

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

I would be very glad if someone can point me in the right direction. Thanks in Advance.

推荐答案

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

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;
    }
}

祝你好运!

这篇关于如何使用 CollectionViewSource 获取多级层次结构以绑定到 Windows 8.1 中的语义缩放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆