Code: Select all
private async Task PickFileAsync()
{
var filePicker = new FileOpenPicker();
filePicker.ViewMode = PickerViewMode.Thumbnail;
filePicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
filePicker.FileTypeFilter.Add(".jpg");
filePicker.FileTypeFilter.Add(".jpeg");
filePicker.FileTypeFilter.Add(".png");
var hwnd = this.XamlRoot.Content.XamlRoot.WindowId;
WinRT.Interop.InitializeWithWindow.Initialize(filePicker, hwnd);
StorageFile file = await filePicker.PickSingleFileAsync();
if (file != null)
{
// Application now has read/write access to the picked file
return file;
}
else
{
return null;
}
}
< /code>
Und so nenne ich die Funktion: < /p>
StorageFile pickedFile = await PickFileAsync();
Es werden nur sehr wenige Artikel gezeigt, sodass ich nicht wirklich viel recherchieren konnte.