问题
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
My model class looks as follows
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
- My ZoomedOutView is a GridView which displays Months like August, July and June.
- In my ZoomedInView the data is grouped by the date
To achieve this I have to create these 3 levels in my CollectionViewSource
- Month
- Date
- Individual Transaction
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
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
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;
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.
回答1:
SemanticZoom: http://msdn.microsoft.com/en-us/library/windows/apps/hh465319.aspx
Try this:
private void Zoom_ViewChangeStarted(object sender, SemanticZoomViewChangedEventArgs e)
{
if (!e.IsSourceZoomedInView)
{
e.DestinationItem.Item = _selectedHubSection;
}
}
Best of luck!
来源:https://stackoverflow.com/questions/25482570/how-to-obtain-multi-level-hierarchy-with-collectionviewsource-to-bind-to-semanti