public static async Task<ImageSource> FromStorageFile(StorageFile sf)
{
using (var randomAccessStream = await sf.OpenAsync(FileAccessMode.Read))
{
var result = new BitmapImage();
await result.SetSourceAsync(randomAccessStream);
return result;
}
}
Use result to set the Source
property of an Image
control either though a Binding
or code-behind
Useful when you need to open images that are stored on the user's disk and not shipped with your application