[WPF] using the pack URI path to access binary resources

Source: Internet
Author: User
Tags format definition

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.