I've got two clear LongListSelectors - without any modification, just dragged from toolbox and changed name.
I'm using code below to fill them (one of them needs to be sorted):
closestList.ItemsSource = spots;
allList.ItemsSource = spots.OrderBy(x => x.name).ToList();
The first list is working fine, but the second one is empty - there is no error. When I change the second line to: allList.ItemsSource = spots;
it's working fine.
What is wrong with that sort?
At the moment that you're writing the code that you have, spots
is empty and contains no items. When you define the source of the data as a reference to spots
it is capable of recognizing when items are added (if spots
is an observable collection, which it does appear to be) which means that in the future, when items get added to spots
, the UI will be updated.
Your second snippet isn't setting the data source as a reference to spots
, but rather as a copy of the collection at that instant in time. At that instant in time it's empty, and since the act of copying it has now divorced that data source from spots
it will never be notified when items are added to spots
, so it stays empty.