1
我m做一個簡單的窗口手機8.1應用程序我想獲得一張照片顯示在應用程序,然後用戶選擇PickMultipleFilesAndContinue .....但即時通訊不知道如何做到這一點。我做這個代碼openfiler選擇器帶我到電話庫.....有沒有其他方式可以在Windows Phone 8.1中獲取照片?如何獲取所有照片與文件挑選器
FileOpenPicker openPicker = new FileOpenPicker();
openPicker.ViewMode = PickerViewMode.Thumbnail;
openPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
openPicker.FileTypeFilter.Add(".jpg");
openPicker.FileTypeFilter.Add(".jpeg");
openPicker.FileTypeFilter.Add(".png");
openPicker.PickMultipleFilesAndContinue();
view.Activated += view_Activated;
}
private async void view_Activated(CoreApplicationView sender, Windows.ApplicationModel.Activation.IActivatedEventArgs args1)
{
FileOpenPickerContinuationEventArgs args = args1 as FileOpenPickerContinuationEventArgs;
bitmapImages = new ObservableCollection<BitmapImage>();
IReadOnlyList<StorageFile> files = args.Files;
if (files.Count > 0)
{
StringBuilder output = new StringBuilder("Picked files:\n");
// Application now has read/write access to the picked file(s)
foreach (StorageFile file in files)
{
output.Append(file.Name + "\n");
using (var stream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read))
{
try
{
BitmapImage bitmapImage = new Windows.UI.Xaml.Media.Imaging.BitmapImage();
bitmapImage.DecodePixelHeight = 200;
bitmapImage.SetSource(stream);
bitmapImages.Add(bitmapImage);
}
catch (ArgumentException Ex)
{
Debug.WriteLine("Exception ", Ex.Message);
}
}
}
ImageCollection.ItemsSource = bitmapImages;
OutputTextBlock.Text = output.ToString();
}
else
{
OutputTextBlock.Text = "Operation cancelled.";
}
}
通過這種方式只有選定的照片。我想所有顯示,然後用戶從他們中選擇.....
我硝基甲苯要單獨添加它們..我在這裏發佈的代碼工作正常,並增加在ImageCollection的圖片,但顯示imageCollectoin所有CAMRA滾動圖片,然後用戶選擇的形式,它..我不希望用戶得到在卡姆拉滾動 –
@AS汗也許我寫它不利。您不必單獨添加照片,代碼會自動完成。而不是使用'listView.Items.Add(image);'你可以使用'bitmapImages.Add(bitmapImage);'。看看我編輯的答案。 – Cristian126