The problem is that the LongListSelector
control requires that its ItemsSource
implements IList
, which CollectionViewSource doesn't do. This means you can't bind a CollectionViewSource
to a LongListSelector
out of the box. You can see this by trying to set it in the code-behind file like this:
myLongListSelector.ItemsSource = myCollectionViewSource.View;
Which gives an error saying it can't convert the view to an IList
.
I know atleast two solutions to this, one is to write a wrapper class around CollectionViewSource which does implement IList and then bind to that. Another question gives an example of this (I haven't tried it thought): LongListSelector grouping using CollectionView in Windows Phone 7 or Windows Phone 8
Another method is to not use CollectionViewSource
and instead using System.Linq
for sorting like suggested in this question: How to Sort a LongListSelector in Windows Phone