サーバーから取得し、LongListSelector でユーザーに表示する非常に長い項目 (約 100) のリストがあります。すべてのアイテムは、写真、名前、およびいくつかの説明です。
主な問題は、リストを ObservableCollection に送信すると、UI が著しく遅くなることです。
上下にスクロールしようとすると、すべてがさらに悪化します。新しいアイテムのレンダリング中に遅延が見られることがあります。
2通りやってみましたが、
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);
と
Dispatcher.BeginInvoke() (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));
どちらの場合も、UI の速度低下が顕著です。