pack://application:,,,//ResourceFile.xaml永远不起作用 [英] pack://application:,,,/ResourceFile.xaml Never Works

查看:132
本文介绍了pack://application:,,,//ResourceFile.xaml永远不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从未能够获得这种引用格式的资源字典来工作.我想念的是什么.

I have never been able to get this format of reference a Resource Dictionary to work. What am I missing.

场景:

使用其中的一些用户控件进行创建和组装.
根本说过文件 {root}/Themes/ColorThemes.xaml
ColorThemes.xaml文件的生成操作设置为资源.
然后在xaml文件中进一步向下说 {root}/Controls/ButtonStyles/Themes/ButtonThemes.xaml (请注意,路径仅是示例)在此文件中,我具有以下代码:

Creating and assembly with some usercontrols in it.
At root have said file {root}/Themes/ColorThemes.xaml
The ColorThemes.xaml file has its build action set to Resource.
Then in in xaml file further down let say {root}/Controls/ButtonStyles/Themes/ButtonThemes.xaml (note the path is just an example) in this file I have the following bit of code:

<ResourceDictionary.MergedDictionaries>
    <ResourceDictionary Source="pack://application:,,,/Themes/ColorThemes.xaml"/>
</ResourceDictionary.MergedDictionaries>

文档指出,这应该可行(据我了解),虽然我在设计器中似乎还不错(所有颜色均已加载等),但是当我随后编译我的应用程序并运行它时,却收到此错误{找不到资源'主题/colorthemes.xaml'.},这很奇怪,因为它似乎在构建器中使用得很好.所以我很困惑,因为它似乎与文档不符.
因此,如果有人可以向我解释我所缺少的内容:)

As far as the documentation states this should work (as I understand it), and while I am in the designer it seems to be fine (all the colors load etc) however when I then go and compile my application and run it I get this error {"Cannot locate resource 'themes/colorthemes.xaml'."} which is strange because it seemed to be using just fine in the builder. So I am quiet confused because it seems to not coincide with the documentation.
So if someone can explain to me what I am missing :)

注意:如果我将以前的代码更改为

Note: if I change the previous code to

<ResourceDictionary.MergedDictionaries>
    <ResourceDictionary Source="../../../Themes/ColorThemes.xaml"/>
</ResourceDictionary.MergedDictionaries>

它工作正常,但是对于cleanese pack://application:.

It works fine, however for cleanese pack://application: .

推荐答案

尝试:

pack://application:,,,/YOURNAMESPACEHERE/ColorThemes.xaml

例如

pack://application:,,,/Themes/ColorThemes.xaml

这篇关于pack://application:,,,//ResourceFile.xaml永远不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆