one, the path format definition
The complete URI is defined as:
pack://application,,, [/optional assembly name;] [optional version;] [Directory Name/] File name
The abbreviated wording is:
[directory Name/] File name
ii. using URI paths in XAML code
Use of the full path:
<image x:name= "IMAGEBG" source= "pack://application:,,,/resources/images/hydrangeas.jpg" Stretch= "Fill"/>
Use of relative paths:
<image x:name= "IMAGEBG" source= "resources/images/hydrangeas.jpg" stretch= "Fill"/>
third, the use of the background code
Relative path. Uri Imageuri = new Uri (@ "resources/images/hydrangeas.jpg", urikind.relative); Imagebg.source = new BitmapImage (Imageuri);//absolute path. Uri Imageuri = new Uri (@ "pack://application:,,,/resources/images/hydrangeas.jpg", urikind.absolute); Imagebg.source = new BitmapImage (Imageuri);
Iv. Matters of note
1. The path is represented by a right-to-left forward slash (/);
2. The use of relative paths in C # code requires that the UriKind must be relative and that the/can be omitted on behalf of the root folder.
3. Complete notation in C # code represents an absolute path. The urikind must be absolute, and the/cannot be omitted to represent the root folder.
4. The path can use DOS-like syntax.
[WPF] using the pack URI path to access binary resources