accessing image files from a separated assembly

落花浮王杯 提交于 2019-12-23 03:44:27

问题


I have several image files I want to share between projects(common icons) I have them in an assembly that would be in every solution I create...I have the files in a folder called Icon and I have the build as content copy always. I have verified that a folder is created with these icons...however my other assemblies are not able to find them...

<r:RibbonGroup Header="Users">
    <r:RibbonButton >
       <r:RibbonButton.LargeImageSource>
            <BitmapImage UriSource="..\Icons\UserIcon.png" />
       </r:RibbonButton.LargeImageSource>
    </r:RibbonButton>
</r:RibbonGroup>

i have tried formatting the uri several ways...but it never succeeds. If the icons are in the actual assembly though they work...


回答1:


Try using an absolute Uri. Build action must be set to Resource for UserIcon.png

<BitmapImage UriSource="pack://application:,,,/NameOfImageAssembly;component/Icons/UserIcon.png"/>

Relative Uri should also work

<BitmapImage UriSource="/NameOfImageAssembly;component/Icons/UserIcon.png"/>


来源:https://stackoverflow.com/questions/4475124/accessing-image-files-from-a-separated-assembly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!