AsyncImageLoader.Avalonia 4.0.0-preview1

This is a prerelease version of AsyncImageLoader.Avalonia.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package AsyncImageLoader.Avalonia --version 4.0.0-preview1
                    
NuGet\Install-Package AsyncImageLoader.Avalonia -Version 4.0.0-preview1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AsyncImageLoader.Avalonia" Version="4.0.0-preview1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AsyncImageLoader.Avalonia" Version="4.0.0-preview1" />
                    
Directory.Packages.props
<PackageReference Include="AsyncImageLoader.Avalonia" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add AsyncImageLoader.Avalonia --version 4.0.0-preview1
                    
#r "nuget: AsyncImageLoader.Avalonia, 4.0.0-preview1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package AsyncImageLoader.Avalonia@4.0.0-preview1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=AsyncImageLoader.Avalonia&version=4.0.0-preview1&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=AsyncImageLoader.Avalonia&version=4.0.0-preview1&prerelease
                    
Install as a Cake Tool

AsyncImageLoader.Avalonia

Provides way to asynchronous bitmap loading for Avalonia Image control.
Features:

  • Supports urls and downloading from web
  • Asynchronous loading
  • Integrated inmemory cache
  • Integrated disk cache
  • Easy to implement your own way of images loading and caching

Getting started

  1. Install AsyncImageLoader.Avalonia nuget package
dotnet add package AsyncImageLoader.Avalonia
  1. Start using

Using

Note: The first time you will need to import the AsyncImageLoader namespace to your xaml file. Usually your IDE should suggest it automatically. The root element in the file will be like this:

<Window ...
        xmlns:asyncImageLoader="clr-namespace:AsyncImageLoader;assembly=AsyncImageLoader.Avalonia"
        ...>
   

Note: Assets and resources in Avalonia described here.

ImageLoader attached property

The only thing you need to do in your xaml is to replace the Source property in Image with ImageLoader.Source.
For example, your old code:

<Image Source="https://mycoolwebsite.io/image.jpg" />

Should turn into:

<Image asyncImageLoader:ImageLoader.Source="https://mycoolwebsite.io/image.jpg" />

Also you can use ImageLoader.IsLoading readonly attached property that indicates whether the load is in progress or not.

AsyncImageLoader support resm: and avares: links. And does not support relative referenced assets such as Source="icon.png" or Source="/icon.png". Use AdvancedImage control.

AdvancedImage control

This control provides all capabilities of ImageLoader attached property and support relative referenced assets such as Source="icon.png" or Source="/icon.png". Before you go, add following style to you App.xaml file and Application.Styles section:

<StyleInclude Source="avares://AsyncImageLoader.Avalonia/AdvancedImage.axaml" />

And you can use AdvancedImage as any other control:

<asyncImageLoader:AdvancedImage Width="150" Height="150" Source="../Assets/cat4.jpg" />

This control allows specifying a custom IAsyncImageLoader for particular control.
Also, this control has loading indicator support out of the box.

ImageBrush

If you need a brush you can use Avalonia's ImageBrush with ImageBrushLoader.Source property (instead of default Source). It will look like that:

<Border>
  <Border.Background>
    <ImageBrush
      asyncImageLoader:ImageBrushLoader.Source="https://mycoolwebsite.io/image.jpg" />
  </Border.Background>
</Border>

Image loading pipeline

ImageLoaderPipeline and ImageLoaderPipelineBuilder are the primary APIs for configuring image loading. The pipeline composes source resolution, external transport, encoded byte caching, bitmap decoding and decoded image retention. Start with the closest builder preset, then replace only the components your application needs to customize:

using AsyncImageLoader.Core;

var loader = ImageLoaderPipelineBuilder.RamCached(new MemoryImageCacheOptions {
    AbsoluteExpiration = TimeSpan.FromMinutes(10),
    SlidingExpiration = TimeSpan.FromMinutes(2)
})
    .UseHttpClient(new HttpClient { Timeout = TimeSpan.FromSeconds(30) })
    .UseDecoder(new MyBitmapDecoder())
    .Build();

ImageLoader.AsyncImageLoader = loader;

The available presets are:

  • Uncached() downloads and decodes each request without retaining the decoded image.
  • RamCached(...) shares decoded images and retains them in the lease-aware RAM cache.
  • DiskCached(...) adds a persistent encoded disk cache for HTTP and HTTPS sources.

All presets use the same default source resolvers, HTTP transport and bitmap decoder. They are starting configurations, not separate extension hierarchies.

Set the resulting pipeline globally through ImageLoader.AsyncImageLoader or ImageBrushLoader.AsyncImageLoader, or assign it to the Loader property of an individual AdvancedImage. Dispose the previous global loader when replacing it.

Pipeline components

  • ImageLoadRequest carries the source string and optional Avalonia context (BaseUri and IStorageProvider) through the pipeline.
  • IImageSourceResolver handles non-network sources. The default CompositeImageSourceResolver tries FileImageSourceResolver, StorageImageSourceResolver and AvaloniaAssetSourceResolver in order.
  • IImageTransport retrieves external encoded data. The default HttpImageTransport handles absolute HTTP and HTTPS sources using HttpClient.
  • IImageByteCache stores encoded image data before decoding. DiskImageByteCache persists HTTP responses under hashed keys and is enabled by the DiskCached(...) preset.
  • IBitmapDecoder converts an encoded stream into an Avalonia Bitmap. The default BitmapDecoder reads non-seekable streams asynchronously before constructing the bitmap.
  • IImageMemoryCache coordinates concurrent requests and returns independent consumer leases. TransientImageCache performs no retention; MemoryImageCache provides RAM retention with absolute and sliding expiration.
  • IImageLease represents one consumer's ownership of an image. UI integrations release their lease when a source is replaced or detached, while the memory cache controls how long its own reference is retained.
  • ImageLoaderPipeline orchestrates these components and implements IAsyncImageLoader.

The builder methods replace individual components:

  • UseSourceResolver(...)
  • UseTransport(...)
  • UseDecoder(...)
  • UseMemoryCache(...)
  • UseByteCache(...)
  • UseHttpClient(...)

The built pipeline owns and disposes its configured memory cache. A supplied HttpClient remains caller-owned unless UseHttpClient(client, disposeHttpClient: true) is used. A builder can build only one pipeline because ownership of its cache is transferred during Build().

Compatibility loaders

The original ready-made loaders remain available as compatibility and convenience facades:

These types delegate to the same pipeline presets. They are useful for existing applications and simple configurations, but new customization should use ImageLoaderPipelineBuilder instead of inheriting from a loader. On mobile, WASM and other restricted platforms, provide a valid writable cache path before using disk caching.

Custom loaders

You can implement every component of the pipeline individually.

Or implement IAsyncImageLoader directly only when the complete built-in pipeline is not appropriate. LoadAsync receives an ImageLoadRequest and returns an IImageLease; such an implementation replaces source resolution, transport, decoding and caching rather than customizing one pipeline stage.

Use ImageLease.Owned, ImageLease.NonOwning or ImageLease.Create to make ownership explicit when implementing a custom loader.

RAM retention

RAM retention can be configured when creating a loader. Expiration releases the loader's strong reference; if the UI still uses the bitmap, it can be reused through a weak reference:

ImageLoader.AsyncImageLoader = ImageLoaderPipelineBuilder.RamCached(new MemoryImageCacheOptions {
    AbsoluteExpiration = TimeSpan.FromMinutes(10),
    SlidingExpiration = TimeSpan.FromMinutes(2)
}).Build();

When both values are specified, the first expiration is used. Expiration never disposes bitmaps that have already been returned to controls.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (7)

Showing the top 5 NuGet packages that depend on AsyncImageLoader.Avalonia:

Package Downloads
ClassIsland.Core

ClassIsland 应用核心依赖库,包括 ClassIsland 封装的一些常用控件和方法。

Huskui.Avalonia.Markdown

Markdown rendering extension for Huskui.Avalonia, converting Markdown text to native Avalonia controls using Markdig.

SuppaWallet.Gui

Package Description

Pwa.Stories

is similar like Instagram Stories

SuppaWallet.Gui.Desktop

Package Description

GitHub repositories (28)

Showing the top 20 popular GitHub repositories that depend on AsyncImageLoader.Avalonia:

Repository Stars
Tyrrrz/YoutubeDownloader
Downloads videos and playlists from YouTube
Tyrrrz/DiscordChatExporter
Saves Discord chat logs to a file
LykosAI/StabilityMatrix
Multi-Platform Package Manager for Stable Diffusion
PixiEditor/PixiEditor
PixiEditor is a Universal Editor for all your 2D needs
Jeric-X/SyncClipboard
跨平台剪贴板同步、历史记录管理工具 / Cross-platform cipboard syncing, history management tool
Tyrrrz/YoutubeExplode
Abstraction layer over YouTube's internal API
ClassIsland/ClassIsland
一款功能强、可定制、跨平台,适用于班级多媒体屏幕的课表信息显示工具,可以一目了然地显示各种信息。
SirDiabo/GithubLauncher
A Launcher that Downloads and Updates Applications from Github Releases
Decimation/SmartImage
Reverse image search tool (SauceNao, IQDB, Ascii2D, trace.moe, and more)
b-editor/beutl
Cross-platform video editing (compositing) software.
Artemis-RGB/Artemis
Provides advanced unified lighting across many different brands RGB peripherals
SnapXL/SnapX
SnapX is a free, open-source, cross-platform tool that lets you capture or record any area of your screen and instantly share it with a single keypress. Upload images, videos, text, and more to multiple supported destinations—all with ease. ShareX fork
rocksdanister/weather
Windows native weather app powered by DirectX12 animations
ETS2LA/ETS2LA
Plugin based interface program for ETS2/ATS.
Linsxyx/KugouMusic.NET
基于 .NET 10 与 Avalonia 打造的轻量级跨平台酷狗音乐客户端。
dorisoy/Dorisoy.Pan
Dorisoy.Pan 是基于 .NET 10 的跨平台文档管理系统,使用 MS SQL 2012 / MySQL 8.0(或更高版本)后端数据库,您可以在 Windows、Linux 或 Mac 上运行它。项目中的所有方法都是异步的,支持 JWT 令牌身份验证,项目体系结构遵循 CQRS + MediatR 模式和最佳安全实践。源代码完全可定制,热插拔且清晰的体系结构,使开发定制功能和遵循任何业务需求变得容易。
HeyM1ke/Assist
C# Valorant Thirdparty Launcher
h4lfheart/FortnitePorting
The quickest and most efficient way to extract assets from Fortnite
EllyVR/VRCVideoCacher
Round-Studio/BedrockBoot
一个为 Windows 和 Linux 开发的基岩版启动器
Version Downloads Last Updated
4.0.0-preview1.2 33 8/22/2026
4.0.0-preview1.1 41 8/21/2026
4.0.0-preview1 93 8/16/2026
3.9.1-nightly.3 61 8/16/2026
3.9.1-nightly.2 62 8/15/2026
3.9.1-nightly.0.1 60 8/10/2026
3.8.0 25,401 4/19/2026
3.7.0 28,345 3/2/2026
3.6.0 19,770 2/1/2026
3.5.0 10,562 12/27/2025
3.4.4 1,224 12/21/2025
3.4.3 25,966 9/14/2025
3.4.2 1,587 9/13/2025
3.4.1 473 9/13/2025
3.4.0 860 9/10/2025
3.3.0 122,833 8/17/2024
3.2.1 43,875 9/26/2023
Loading failed

## What's Changed
* Composition loaders pipelines and bitmap ownership by @SKProCH in https://github.com/AvaloniaUtils/AsyncImageLoader.Avalonia/pull/48


**Full Changelog**: https://github.com/AvaloniaUtils/AsyncImageLoader.Avalonia/compare/v3.9.0...v4.0.0-preview1