Reputation: 1943
I'm working on a WPF/XAML interface. Using the SharpVector.Reloaded package, I want to show a SVG image file inside an Image component. The source file is located on my HDD.
If I use an absolute path to my file:
<Image x:Name="imImage" Grid.Column="1" Source="{svgc:SvgImage Source=W:/Labo/WPF/SVG/SVG/Resources/Images/Ghost.svg}"/>
all works fine, the image is visible.
Now I want to turn the path relative. I tried all the ways I could imagine to do that, but no way! Even the following code, which normally should work with e.g. a Source property, isn't working here:
<Image x:Name="imImage" Grid.Column="1" Source="{svgc:SvgImage Source=pack://siteoforigin:,,,/Resources/Images/Ghost.svg}"/>
Doing that I get a list of 9 errors:
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 '
So can someone explain me what I'm doing wrong here, and what is the so well kept secret to declare a relative path in the above described context?
And as an additional question, why did WPF need to make relative paths as complicated to use?
Upvotes: 0
Views: 828
Reputation: 4322
You need to put single quotes around the pack URI.
The XAML parser doesn't realize you're trying to set Source to all of that so you get errors.
<Image x:Name="imImage" Grid.Column="1" Source="{svgc:SvgImage Source='pack://siteoforigin:,,,/Resources/Images/Ghost.svg'}"/>
I just tried it and it works.
Upvotes: 1