I am trying to do this...
<Image x:Name="imgGroupImage" Source="Images\unlock.png" Margin="0,0,5,0" />
But I get this error...
Cannot convert string 'Images\unlock.png' in attribute 'Source' to object of type 'System.Windows.Media.ImageSource'. Cannot locate resource 'forms/images/unlock.png'. Error at object 'System.Windows.HierarchicalDataTemplate' in markup file 'Fuse;component/forms/mainwindow.xaml' Line 273 Position 51.
As you can see, my form that includes this XAML is in a folder named Forms. My Images are in a folder named Images. How do I map from Forms to Images?
I tried Source="..Images\unlock.png"
which does not work in WPF.
Any help?
Click the Start button and then click Computer, click to open the location of the desired file, hold down the Shift key and right-click the file. Copy As Path: Click this option to paste the full file path into a document. Properties: Click this option to immediately view the full file path (location).
A XAML namespace is really an extension of the concept of an XML namespace. The techniques of specifying a XAML namespace rely on the XML namespace syntax, the convention of using URIs as namespace identifiers, using prefixes to provide a means to reference multiple namespaces from the same markup source, and so on.
The Path object represents a path shape and draws a path. The Path object draws both closed and open paths. A closed path is a shape that has the same start and end points and an open path is a shape that has different start and end points. The Fill property fills the interior of an ellipse.
A path is a slash-separated list of directory names followed by either a directory name or a file name. A directory is the same as a folder.
Try slashes rather than backslashes, and use an absolute path by leading with a slash:
Source="/Images/unlock.png"
That generally works for me.
Failing that, take a look at Pack URIs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With