【发布时间】:2020-07-10 13:18:14
【问题描述】:
所以我从 WPF 切换到 Avalonia 以用于我的应用程序的跨平台使用。 WPF 支持图像的相对路径。但是当我切换到 Avalonia 时,将 Window 的背景设置为 ImageBrush,并使用 Image 的相对路径源(类似于 Images/Background.png),它会输出:
System.IO.FileNotFoundException: 'The resource Images/Background.png could not be found.'
我一开始以为是因为字符串不能转换成IBitmap接口,但后来我意识到给它绝对路径时我错了(类似于C:\Users\username\source\repos\MySolution\MyProject\Images\Background.png)。
我该如何解决这个问题?
编辑:Images/Background.png 被复制到输出目录,我使用的是 Visual Studio 2019。
【问题讨论】:
标签: .net-core avaloniaui