0

サーバーから取得し、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 の速度低下が顕著です。

4

1 に答える 1

0

Ritch Melton による最終版:

_items = groupedObjects.ToList();
Deployment.Current.Dispatcher.BeginInvoke(() => 
                        RaisePropertyChanged("FoundProductItems", _items, _items, true)); // using shortcut from MVVMlight
于 2013-07-01T20:40:10.380 に答える