Open logixoul opened 4 months ago
Did you try using the full rooted path? Maybe something like:
<Image Margin="20" Height="200" Width="200" Source="../assets/logo.png"/>
Or the relative path:
<Image Margin="20" Height="200" Width="200" Source="../logo.png"/>
Or perhaps
<Image Margin="20" Height="200" Width="200" Source="logo.png"/>
@Eugenenoble2005 yep, to no avail.
@Eugenenoble2005 yep, to no avail.
Maybe avalonia can't reach it from outside the project. If you really need it outside the project, try creating a shared class library, put the assets there and try to access the resource via the assembly name
<Image Source="avares://sharedAssembly/Assets/icon.png"/>
Please use Link msbuild attribute to assign more compiler-friendly path to your assets:
<ItemGroup>
<AvaloniaResource Include="../assets/**"
Link="assets/%(RecursiveDir)%(FileName)%(Extension)" />
</ItemGroup>
Once we support LinkBase, it will be easier as well https://github.com/AvaloniaUI/Avalonia/pull/16118
Describe the bug
Relative paths in the AvaloniaResource tag don't seem to work.
To Reproduce
I have this filesystem structure: -- MySolution/ --- assets/ ---- logo.png --- MyProject/ ---- MyProject.csproj
I added this to my csproj file:
... and this to MainWindow.axaml:
Got a System.IO.FileNotFoundException.
When I move the assets dir into the MyProject dir and change the AvaloniaResource line to say "assets**", things work fine. Maybe I'm doing something wrong, but I think this is a bug.
Expected behavior
No response
Avalonia version
11.0.10
OS
Windows
Additional context
No response