Try the following:
public async Task<BitmapImage> GetBitmapAsync(StorageFile storageFile) { BitmapImage bitmap = new BitmapImage(); IAsyncOperation<IRandomAccessStream> read = storageFile.OpenReadAsync(); IRandomAccessStream stream = await read; bitmap.SetSource(stream); return bitmap; }
Call the function as follows:
Image image = new Image(); image.Source = await GetBitmapAsync (file);
source share