ObservableCollection<Photo>
から取得したオブジェクトのリストでWrapPanel
を入力するWindows Phone 7用のアプリケーションを開発しています。ユーザーがPanelTemplateとしてWrapPanelを使用してコンテンツをスクロールするときに、タイプImageのListboxItemをロードすることは可能ですか?
<ListBox ItemsSource="{Binding Photo}">
<ListBox.ItemTemplate>
<DataTemplate>
<Image Source="{Binding File}" />
</DataTemplate>
</ListBox.ItemTemplate>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<toolkit:WrapPanel ItemHeight="150" ItemWidth="150" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>
(それがすべてのイメージのロードだ手段で)動作するようになっていますどのように働いているが、私はWrapPanel : Panel
以来、いくつかのパフォーマンス上の問題を抱えています。したがって、ユーザーが見ることができないものであっても、ListBox
のすべてのImage
オブジェクトをロードするデータは仮想化されません。
このアプローチは、ObservableCollection<Photo>.Count <= 30
ではなく、Collection
が大きくなるにつれて遅くなる場合があります。
ユーザーは最大1000個の画像を持つことができるので、単純にこのようには動作しません。サムネイルを束縛してImageオブジェクトを表示していますが。
私はDavid Anson's LowProfileImageLoaderを使用して、UIスレッドから画像を作成しようとしました。また、ユーザーがListBox
をスクロールするときにイメージをバインドする。しかし、画像がIsolatedStorage
から読み込まれているので、UriSource
が予想され、実際にBitmapImage
をImage.Source
にバインドしているので、動作しません。
public class Photo : INotifyPropertyChanged, INotifyPropertyChanging
{
...
...
public BitmapImage File
{
get
{
// Thumbnail
string filePath = Path.Combine("Images", FileName);
byte[] data;
using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication())
{
using (IsolatedStorageFileStream isfs = isf.OpenFile(filePath, FileMode.Open, FileAccess.Read))
{
data = new byte[isfs.Length];
isfs.Read(data, 0, data.Length);
isfs.Close();
}
}
MemoryStream ms = new MemoryStream(data);
BitmapImage bi = new BitmapImage();
bi.SetSource(ms);
return bi;
}
}
}
ユーザーがそれを見ていると誰もがコンテンツ(写真)負荷を作るこのタスクで私を助けることができますか? VirtualizingWrapPanel
やWrapPanel : VirtualizingPanel
などはありますか?
ありがとうございました。コードスニペットが必要な場合は、お気軽にお問い合わせください。
[WP7 Virtualizing WrapPanel]の可能な複製(http:// stackoverflow。com/questions/5046810/wp7-virtualizing-wrappanel) – nemesv
商用の[ラップパネルの仮想化](http://www.binarymission.co.uk/Products/WPF_SL/virtualizingwrappanel_wpf_sl.htm)もあります。 – nemesv
@nemesv私は見ましたこの質問は答えは私の問題を解決していないので、私はVirtualizedWrapPanelだけでなく、実際にリストを滑らかにするための回避策を求めています。私はまた、できるだけ明確に私の質問をしようとするいくつかのコードを抜粋しました – Matheus