【发布时间】:2019-07-15 17:36:06
【问题描述】:
我正在开发 WPF/XAML 接口。使用 SharpVector.Reloaded 包,我想在 Image 组件中显示 SVG 图像文件。源文件位于我的硬盘上。
如果我使用文件的绝对路径:
<Image x:Name="imImage" Grid.Column="1" Source="{svgc:SvgImage Source=W:/Labo/WPF/SVG/SVG/Resources/Images/Ghost.svg}"/>
一切正常,图像可见。
现在我想把路径变成相对的。我尝试了所有我能想到的方法,但没有办法!甚至以下代码,通常应该与例如源属性,在这里不起作用:
<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 需要使相对路径使用起来很复杂?
【问题讨论】:
标签: c# wpf xaml url relative-path