UWP File display control code example
Example 1: uwp file open picker
var openPicker = new Windows.Storage.Pickers.FileOpenPicker();
openPicker.viewMode = Windows.Storage.Pickers.PickerViewMode.thumbnail;
openPicker.suggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.picturesLibrary;
openPicker.fileTypeFilter.replaceAll([".png", ".jpg", ".jpeg"]);
openPicker.pickSingleFileAsync().then(function (file) {
if (file) {
WinJS.log && WinJS.log("Picked photo: " + file.name, "sample", "status");
} else {
WinJS.log && WinJS.log("Operation cancelled.", "sample", "status");
}
});
Example 2: uwp file open picker
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)
{
OutputTextBlock.Text = "Picked photo: " + file.Name;
}
else
{
OutputTextBlock.Text = "Operation cancelled.";
}