【发布时间】:2023-03-15 16:52:01
【问题描述】:
我正在使用一个按钮从图片文件夹中选择一个图像,我想要将所选图像保存到应用程序的本地存储中,以便能够使用 GridView 中的绑定显示该图像。这可能吗?我怎么能做到?谢谢
【问题讨论】:
标签: image binding windows-8 microsoft-metro windows-runtime
我正在使用一个按钮从图片文件夹中选择一个图像,我想要将所选图像保存到应用程序的本地存储中,以便能够使用 GridView 中的绑定显示该图像。这可能吗?我怎么能做到?谢谢
【问题讨论】:
标签: image binding windows-8 microsoft-metro windows-runtime
你会这样做:
FileOpenPicker openPicker = new FileOpenPicker();
openPicker.ViewMode = PickerViewMode.Thumbnail;
openPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
openPicker.FileTypeFilter.Add(".jpg");
openPicker.FileTypeFilter.Add(".jpeg");
openPicker.FileTypeFilter.Add(".png");
StorageFile file = await openPicker.PickSingleFileAsync();
if (file != null)
{
await file.CopyAsync(Windows.Storage.ApplicationData.Current.LocalFolder);
}
【讨论】: