I am not aware if there is any “callback” to Listview creation so that i can display very specific type of data from the List i have.
What i know is that only Complete List can be bound to the ListView, but how can i put some checking to it like its done in iOS by the help of Datasource Delegate.
Anyone ?
Filtering and grouping has traditionally be done with CollectionViewSource. Unfortunately, CollectionViewSource no longer has the Filter event or the GroupDescriptions property. It may seem like filtering and grouping are unsupported, but both can still be achieved using LINQ.
In your Xaml, add a CollectionViewSource in the Resources section of your page. Make sure IsSourceGrouped is set to true:
Now, the CollectionViewSource (GroupsCV) should be set as the ItemsSource for your GridView:
Notice that CollectionViewSource is bound to a property called Groups. This property is part of my ViewModel. The value returned by the Groups property will be the result of a LINQ query. This confused me at first because I didn’t know what type the property should return. I settled on an enumerable grouping of comparable items. This pretty much works with any LINQ query of any type.
So, in your ViewModel (or whatever your DataContext is) add the following property:
Now, whenever you want to change the grouping or the filter, just set the Groups property equal to a LINQ query like so:
LINQ does great with known property names, but what about letting the user pick from a list of property names and dynamically grouping by that property? Well, the only requirement for LYNQ to be able to create a group is that whatever you pass it must implement IComparable.
Here’s a little extension method that takes the name of a property as a string and returns an IComparable:
With that in place, you can do a dynamic query by property name like this:
Hope that helps!