Is there a way to group collection items in the XAML code in windows store apps. In WPF you can use a CollectionViewSource
and than use its property CollectionViewSource.GroupDescriptions
or something like that, but for Windows Store apps it doesnt work. I know i can use a Linq query in the code behind, but is there an alternative that is grouping with code declared in XAML?
2 Answers
You're probably not in need for an answer anymore, but I found this question while looking for something similar and also just recently stumbled across an article that probably perfectly answers your question. This might be helpful for someone else later.
How to group items in a list or grid (Windows Store apps using C#/VB/C++ and XAML)
There's grouping of a ListView and querying with LINQ, just what you were asking for.
In WPF, one can group and filter within XAML using CollectionViewSource
's GroupDescriptions
property and Filter
event. In Windows Store apps, on the other hand,CollectionViewSource
does not have this property and event. All is not lost, however. Filtering and grouping are still supported, but only by feeding your ItemsControl
(e.g. GridView
) a collection that is already grouped or filtered. The MSDN docs provide step-by-step instructions on how to accomplish this.