doc/articles/features/image.md
This page details the specific aspects of the Image control for Uno Platform. General information about Image is available in WinUI official documentation.
ms-appxms-appx supports reading images provided as Content assets in your project. See StorageFile.GetFileFromApplicationUriAsync for more details.
ms-appdatams-appdata:/// supports reading content from the some known folders of an app.
For instance, these are paths which can be used to show images:
ms-appdata:///local/myimage.png, using the path from ApplicationData.Current.LocalFolderms-appdata:///temp/myimage.png, using the path from ApplicationData.Current.TemporaryFolderms-appdata:///roaming/myimage.png, using the path from ApplicationData.Current.RoamingFolderFiles written at those locations will be shown in the Image control.
Here's a simple example:
var httpClient = new HttpClient();
var response = await httpClient.GetAsync("https://fakeimg.pl/300/");
var file = await ApplicationData.Current.LocalFolder.CreateFileAsync("image.jpg", CreationCollisionOption.ReplaceExisting);
using (var stream = await file.OpenStreamForWriteAsync())
{
await response.Content.CopyToAsync(stream);
}
MyImage.UriSource = new BitmapImage { UriSource = new($"ms-appdata:///local/image.jpg") };
[!IMPORTANT] When using WinAppSDK Unpackaged mode,
ms-appdata:///is not supported onImage. In this case, you can useBitmapImage.SetSourceAsyncto set the image programmatically.
Displaying animated GIFs is supported on:
Unsupported targets, where only the first frame is shown, as of Uno Platform 5.4: