AsyncImageLoader.Avalonia 3.3.0

dotnet add package AsyncImageLoader.Avalonia --version 3.3.0                
NuGet\Install-Package AsyncImageLoader.Avalonia -Version 3.3.0                
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="3.3.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AsyncImageLoader.Avalonia --version 3.3.0                
#r "nuget: AsyncImageLoader.Avalonia, 3.3.0"                
#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.
// Install AsyncImageLoader.Avalonia as a Cake Addin
#addin nuget:?package=AsyncImageLoader.Avalonia&version=3.3.0

// Install AsyncImageLoader.Avalonia as a Cake Tool
#tool nuget:?package=AsyncImageLoader.Avalonia&version=3.3.0                

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>

Loaders

ImageLoader will use instance of IImageLoader for serving your requests.
You can change the loader used by setting new one to the ImageLoader.AsyncImageLoader property. Do not forget to Dispose previous loader.
There are several loaders available out of the box:

  • BaseWebImageLoader - Provides non cached way to asynchronously load images without caching. Can be used as base class for custom loaders you dont want caching in any way.
  • RamCachedWebImageLoader - This is inheritor if BaseWebImageLoader with in memory images caching. Can be used as base class for custom loaders you want only inmemory caching.
  • DiskCachedWebImageLoader - This is inheritor if RamCachedWebImageLoader with in memory caching and disk caching for downloaded from the internet images. Can be used as base class for custom loaders if you want disk caching out of the box.

RamCachedWebImageLoader are used by default.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

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

Package Downloads
Pwa.Stories

is similar like Instagram Stories

Iciclecreek.AdaptiveCards.Rendering.Avalonia

AdaptiveCard renderer for AvaloniauUI

GitHub repositories (13)

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

Repository Stars
Tyrrrz/YoutubeDownloader
Downloads videos and playlists from YouTube
Tyrrrz/DiscordChatExporter
Exports Discord chat logs to a file
LykosAI/StabilityMatrix
Multi-Platform Package Manager for Stable Diffusion
Tyrrrz/YoutubeExplode
Abstraction layer over YouTube's internal API
PixiEditor/PixiEditor
PixiEditor is a pixel art editor made with .NET 8
Version Downloads Last updated
3.3.0 9,341 8/17/2024
3.2.1 30,102 9/26/2023
3.2.1-rc1 122 9/23/2023
3.2.0 2,977 8/8/2023
3.1.0 336 7/30/2023
3.0.0 728 7/17/2023
3.0.0-avalonia11-preview6 795 6/1/2023
3.0.0-avalonia11-preview5 166 5/27/2023
3.0.0-avalonia11-preview4 457 3/27/2023
3.0.0-avalonia11-preview3 630 2/6/2023
3.0.0-avalonia11-preview2 390 11/13/2022
3.0.0-avalonia11 1,438 8/23/2022
2.5.0 410 5/22/2023
2.4.0 4,222 7/19/2022
2.3.0 438 7/16/2022
2.2.0 653 6/18/2022
2.1.1 455 6/8/2022
2.1.0 458 11/13/2021
2.0.1 332 11/10/2021
2.0.0 307 11/10/2021
1.0.0 394 11/9/2021

## What's Changed
* Add errors logging to loaders by @SKProCH in https://github.com/AvaloniaUtils/AsyncImageLoader.Avalonia/pull/24

## New Contributors
* @SKProCH made their first contribution in https://github.com/AvaloniaUtils/AsyncImageLoader.Avalonia/pull/24

**Full Changelog**: https://github.com/AvaloniaUtils/AsyncImageLoader.Avalonia/compare/v3.2.1...v3.3.0