【发布时间】:2014-04-08 09:30:13
【问题描述】:
我正在开发一个应用程序,用户可以在其中添加 Windows phone 7 照片库中的照片并将它们分配给特定视图。为此,我将 OriginalFileName 保存在数据库(LINQ to SQL)上。稍后我想恢复照片并将其加载到视图中。你知道我能做什么吗?目前我有这个代码,但不起作用。
当用户选择图片时,我将他的名字保存在变量 fileName 中:
private void photoChooserTask_Completed (object sender, PhotoResult e)
{
BitmapImage image = new BitmapImage ();
e.OriginalFileName = fileName;
image.SetSource (e.ChosenPhoto);
this.Thumbnail.Source = image;
this.Thumbnail.Stretch = Stretch.UniformToFill;
}
稍后,当用户想要保存此设置时,我将文件名保存在数据库中。
这是我加载必须包含照片的视图时的代码。
imgSource var = new BitmapImage (new Uri (picture.Url, UriKind.Absolute));
item.LeftImage.Source = imgSource;
其中picture.Url 包含文件名。
有什么想法吗?我在互联网上看到,您可以保留整个图像,但要尽可能做到最好。
【问题讨论】:
标签: windows-phone-7