zoukankan      html  css  js  c++  java
  • WPF 中资源路径的问题

    WPF 中资源路径的问题

    1. 引用当前工程的资源(注意xxxx.png的build action 应设置为Resource 或Embedded Resource)

    <ImageBrush ImageSource="/currentAssemblyName;component/subfoldername/xxxx.png"/>
    

    2.引用其它工程的资源  (注意xxxx.png的build action 应设置为Resource 或Embedded Resource)

    <ImageBrush ImageSource="pack://application:,,,/otherAssemblyName;component/subfolder/xxx.png"/> 
    

    3.引用相对路径下的资源(注意最好将xxx.png 的copy to output directory属性设置成 always copy )

    <ImageBrush ImageSource="pack://siteoforigin:,,,./subfolder/xxx.png "/>
    

    4.引用绝对路径下的资源

    <ImageBrush ImageSource="C:	estxxx.png"/>  
    

    5.当在使用pack 前缀的路径时,如果出现如下错误:System.UriFormatException: Invalid URI: Invalid port specified, 而你使用的pack路径又确实没有错误。这是因为pack:// scheme 没有注册,解决方案有两个:

    a.       实例化一个System.Windows.Application, 在实例化过程中会调用PackUriHelper class

    if (!UriParser.IsKnownScheme("pack"))   
    {  
            new System.Windows.Application();   
    }  
    

    b.      调用一次System.IO.Packaging.PackUriHelper.UriSchemePack  

    string s = System.IO.Packaging.PackUriHelper.UriSchemePack;  
    

      

  • 相关阅读:
    cadence中画焊盘注意事项
    频率带宽解释
    一种RC滤波电路的验证
    24L01-2.4G无线传输模块调节记录
    51中xdata,idata,data,pdata的区别
    调试24L01经验总结
    将scl分频
    I2C详细介绍
    汽车电源系统概述
    PCB命名规则-allegro
  • 原文地址:https://www.cnblogs.com/cw_volcano/p/3779645.html
Copyright © 2011-2022 走看看