そもそもそのメモリを使い果たしてはどうでしょうか。
(注:次の段落とコードは、この回答から複製されています。)
問題の一部は、それぞれに完全な画像をロードしていることです。のまたはプロパティのいずれかを設定して、を使用IValueConverter
してサムネイルサイズで各画像を開く必要があります。これが私のプロジェクトの1つで使用する例です...DecodePixelWidth
DecodePixelHeight
BitmapImage
class PathToThumbnailConverter : IValueConverter {
public int DecodeWidth {
get;
set;
}
public PathToThumbnailConverter() {
DecodeWidth = 200;
}
public object Convert( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture ) {
var path = value as string;
if ( !string.IsNullOrEmpty( path ) ) {
FileInfo info = new FileInfo( path );
if ( info.Exists && info.Length > 0 ) {
BitmapImage bi = new BitmapImage();
bi.BeginInit();
bi.DecodePixelWidth = DecodeWidth;
bi.CacheOption = BitmapCacheOption.OnLoad;
bi.UriSource = new Uri( info.FullName );
bi.EndInit();
return bi;
}
}
return null;
}
public object ConvertBack( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture ) {
throw new NotImplementedException();
}
}
コンバーターがバックグラウンドスレッドで呼び出されるように、を検討IsAsync=True
することもできます。Binding