// 最近更新 图片加载 private async void Image_Loaded_1(object sender, RoutedEventArgs e) { try { var image = sender as Image; var item = image.DataContext as ViewModels.ScheduleModel; BitmapImage bitmap = new BitmapImage(); using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication()) { string filePath = "/Cache/" + item.aid + "_1.jpg"; if (isf.FileExists(filePath)) { using (IsolatedStorageFileStream stream = isf.OpenFile(filePath, FileMode.Open)) { bitmap.SetSource(stream); } } else { HttpEngine httpRequest = new HttpEngine(); Stream stream = await httpRequest.GetAsyncForData("http://images.movie.xunlei.com/submovie_img/" + item.aid[0] + item.aid[1] + "/" + item.aid + "/1_1_115x70.jpg"); bitmap.SetSource(stream); if (!isf.DirectoryExists("/Cache")) { isf.CreateDirectory("/Cache"); } using (IsolatedStorageFileStream writeStream = isf.OpenFile(filePath, FileMode.Create)) { WriteableBitmap wb = new WriteableBitmap(bitmap); wb.SaveJpeg(writeStream, wb.PixelWidth, wb.PixelHeight, 0, 100); writeStream.Close(); } } } image.Source = bitmap; Storyboard storyboard = new Storyboard(); DoubleAnimation animation = new DoubleAnimation(); animation.From = 0; animation.To = 1; animation.Duration = new Duration(TimeSpan.FromMilliseconds(500)); Storyboard.SetTarget(animation, image); Storyboard.SetTargetProperty(animation, new PropertyPath(Image.OpacityProperty)); storyboard.Children.Add(animation); storyboard.Begin(); } catch { // do nothing } }