【发布时间】:2014-02-09 10:47:57
【问题描述】:
我正在将我的 Windows Phone 8 应用程序移植到 Windows 8,我需要选择一张图片并为其设置图片来源!我今天必须移植它。我用这个:
FileOpenPicker openPicker = new FileOpenPicker();
openPicker.ViewMode = PickerViewMode.Thumbnail;
openPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
openPicker.FileTypeFilter.Add(".jpg");
openPicker.FileTypeFilter.Add(".jpeg");
openPicker.FileTypeFilter.Add(".png");
Windows.Storage.StorageFile file = await openPicker.PickSingleFileAsync();
if (file != null)
{
BitmapImage img = new BitmapImage() { UriSource = new Uri((file.Path + file.DisplayName + file.FileType), UriKind.RelativeOrAbsolute) };
image.Source = img;
}
else
{
}
它选择了图像,但它没有更改源,我也使用了:
FileOpenPicker openPicker = new FileOpenPicker();
openPicker.ViewMode = PickerViewMode.Thumbnail;
openPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
openPicker.FileTypeFilter.Add(".jpg");
openPicker.FileTypeFilter.Add(".jpeg");
openPicker.FileTypeFilter.Add(".png");
Windows.Storage.StorageFile file = await openPicker.PickSingleFileAsync();
if (file != null)
{
BitmapImage img = new BitmapImage() { UriSource = new Uri(file.Path, UriKind.RelativeOrAbsolute) };
bustin.Source = img;
dt.Start();
oyunsure.Start();
}
else
{
dt.Start();
oyunsure.Start();
}
但两者都不起作用。
【问题讨论】:
标签: c# windows windows-8 photo