I have a quite long list of items (about 100) , which I am getting from server and that I show to an user in a LongListSelector. Every item is a picture, name and some description.
The main problem is that when I am sending the list to ObservableCollection, that it noticeably slows down the ui.
Everything is even worse, when I am trying to scroll up and down: sometimes I can see delay during the rendering of new items.
I tried it 2 ways,
using TaskEx.Run():
var answer = await shoppingCartListDataService.GetShoppingListAsync();
var groupedObjects = await TaskEx.Run(() => from item in answer.collection
group item by
item.name[0].ToString(CultureInfo.InvariantCulture)
into it
orderby it.Key
select
new ProductSearchCategoryCollection<ProductItem>(
it.Key, it.OrderBy(i => i.SumPrice)));
FoundProductItems = new ObservableCollection<ProductSearchCategoryCollection<ProductItem>>(groupedObjects);
and
Dispatcher.BeginInvoke() (called from ThreadWorker)
var answer = await shoppingCartListDataService.GetShoppingListAsync();
var groupedObjects = from item in answer.collection
group item by item.aisle
into it
orderby it.Key
select
new ProductSearchCategoryCollection<ProductItem>(it.Key, it.OrderBy(i => i.SumPrice));
Deployment.Current.Dispatcher.BeginInvoke(() =>
FoundProductItems = new ObservableCollection<ProductSearchCategoryCollection<ProductItem>>(groupedObjects));
In the both cases the ui slowdown is noteable.