Search code examples
imageassetsavaloniauiavalonia

AvaloniaLocator Current does not exists Linux


AvaloniaLocator.Current is not a public property and in the docs that I read they all use it. So im trying to update an image if it is a folder or file but I read that you have to convert it yourself so i did this

var assets = AvaloniaLocator.Current.GetService<IAssetLoader>();
var asset = assets.Open(uri);

but apparently AvaloniaLocator.Current is internal


Solution

  • I shortly figured it out after a bit more digging you will have to replace var assets = AvaloniaLocator.Current.GetService<IAssetLoader>(); with the new class AssetLoader, it is explained better in https://github.com/AvaloniaUI/Avalonia/wiki/Avalonia-11-Porting-Guide