我正在开发 WPF/XAML 界面。使用 SharpVector.Reloaded 包,我想在图像组件内显示 SVG 图像文件。源文件位于我的硬盘上。如果我使用文件的绝对路径:<Image x:Name="imImage" Grid.Column="1" Source="{svgc:SvgImage Source=W:/Labo/WPF/SVG/SVG/Resources/Images/Ghost.svg}"/>一切正常,图像可见。现在我想将路径变为相对路径。我尝试了所有我能想到的方法来做到这一点,但没有办法!即使下面的代码(通常应该与 Source 属性一起使用)在这里也不起作用:<Image x:Name="imImage" Grid.Column="1" Source="{svgc:SvgImage Source=pack://siteoforigin:,,,/Resources/Images/Ghost.svg}"/>这样做我得到了 9 个错误的列表:Error XDG0052 The unnamed argument "" must appear before named arguments. SVG MainWindow.xaml 18 Error XLS0112 Expected ''. SVG MainWindow.xaml 18 Error XLS0414 The type '' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built. SVG MainWindow.xaml 18 Error XLS0112 Expected ''. SVG MainWindow.xaml 18 Error XLS0414 The type '' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built. SVG MainWindow.xaml 18 Error XLS0112 Expected ''. SVG MainWindow.xaml 18 Error XLS0414 The type '' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built. SVG MainWindow.xaml 18 Error XLS0112 Expected '}'. SVG MainWindow.xaml 18 Error XLS0112 Expected '那么有人可以解释一下我在这里做错了什么,以及在上述上下文中声明相对路径的如此保密的秘密是什么?另外一个问题是,为什么 WPF 需要使相对路径使用起来如此复杂?
1 回答

绝地无双
TA贡献1946条经验 获得超4个赞
您需要在包 URI 两边加上单引号。
XAML 解析器没有意识到您正在尝试将 Source 设置为所有这些,因此会出现错误。
<Image x:Name="imImage" Grid.Column="1" Source="{svgc:SvgImage Source='pack://siteoforigin:,,,/Resources/Images/Ghost.svg'}"/>
我刚刚尝试过并且有效。
- 1 回答
- 0 关注
- 280 浏览
添加回答
举报
0/150
提交
取消