Problems with resource paths in WPF

Source: Internet
Author: User

Source: Problems with resource paths in WPF

? Problems with resource paths in WPF

1. Referencing resources for the current project (note that the build action for Xxxx.png should be set to Resource or embedded Resource)

[CSharp]? View Plaincopy
    1. <imagebrush? imagesource="/currentassemblyname;component/subfoldername/xxxx.png"/>??

?

2. Reference to resources of other projects? (Note that the build action for Xxxx.png should be set to Resource or embedded Resource)

[HTML]? View Plaincopy
  1. <ImageBrush?ImageSource="pack://application:,,,/otherassemblyname;component/subfolder/xxx.png"/>??

?

3. Referencing resources under relative paths (note it is best to set the copy to Output directory property of Xxx.png to always copy)

[HTML]? View Plaincopy
  1. <ImageBrush?ImageSource="Pack://siteoforigin:,,,./subfolder/xxx.png?"/>??

?

4. Reference a resource under an absolute path?

[HTML]? View Plaincopy
  1. <ImageBrush?ImageSource="C:\test\xxx.png"/>??

?

5. When using the path of the pack prefix, if the following error occurs:System.UriFormatException:Invalid uri:invalid Port specified, and the pack path you are using does not have an error. This is because pack://scheme is not registered and there are two solutions:

A.?????? Instantiates a System.Windows.Application that is called PackUriHelper class during instantiation

[CSharp]? View Plaincopy
  1. if ? (! Uriparser.isknownscheme ("pack"))???
  2. {??
  3. ???????? New ? System.Windows.Application ();???
  4. }??

?

B.????? Call once System.IO.Packaging.PackUriHelper.UriSchemePack????

[CSharp]? View Plaincopy
    1. string ? s?=? System.IO.Packaging.PackUriHelper.UriSchemePack;?

Problems with resource paths in WPF

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.