我在 IsolatedStorage 中有 1000 多个图像(拇指),需要在 JumpList 中显示它们
我有一个 XAML 代码:
<telerikData:RadJumpList telerikCore:InteractionEffectManager.IsInteractionEnabled="True" Name="TitleCollection" ItemsSource="{Binding TitleCollection}">
<telerikData:RadJumpList.ItemTemplate >
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Image Source= "{Binding Cover}" CacheMode="BitmapCache" />
<TextBlock Text="{Binding FirstLine}" />
<StackPanel>
</DataTemplate>
和模型
public class TitleList : ViewModelBase
{
public String Id_on_server { get; set; }
public String FirstLine
{
get;set;
}
private static Mutex _mut = new Mutex(false,"mutex control");
BitmapImage _Cover;
public BitmapImage Cover
{
get
{
if (_Cover == null)
{
BackgroundWorker bw = new BackgroundWorker();
bw.DoWork += new DoWorkEventHandler(
(object sender, DoWorkEventArgs e) =>
{
String fileName = App.ImageDirectory + "/" + this.Id_on_server + "_front_thumb.jpg";
Deployment.Current.Dispatcher.BeginInvoke(delegate()
{
using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
{
if (myIsolatedStorage.FileExists(fileName))
{
try
{
_Cover = new BitmapImage();
_Cover.SetSource(myIsolatedStorage.OpenFile(fileName, FileMode.Open, FileAccess.Read));
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.Message);
}
}
else
{
_Cover = new BitmapImage();
_Cover.UriSource = new System.Uri("/Image/Movie.Icon.Default.png", System.UriKind.Relative);
}
}
});
});
bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(
(object sender, RunWorkerCompletedEventArgs e) =>
{
_mut.ReleaseMutex();
Deployment.Current.Dispatcher.BeginInvoke(delegate()
{
RaisePropertyChanged("Cover");
});
}
);
_mut.WaitOne();
bw.RunWorkerAsync();
}
return _Cover;
}
set
{
_Cover = value;
RaisePropertyChanged("Cover");
}
}
}
所以我从后台的隔离存储中获取图像并显示在列表中。此代码有效,但如果 JumpList 快速滚动,则会发生显示项目的强烈延迟。
谁能建议如何正确显示大量图片或像 LowProfileImageLoader 一样制作称职的 LoadDelay。任何建议或示例都会有所帮助。