访问特定资源字典中的资源

发布于 2024-10-13 12:32:11 字数 168 浏览 11 评论 0原文

我想在我的应用程序中拥有多个资源字典并访问特定资源字典中定义的资源。这可能吗?根据我所读到的内容,查找特定密钥是一个本机过程,我们无法控制它。事实上,我会对不同资源字典中的多个资源使用相同的密钥。如果我采用当前的过程,则仅使用层次结构树中最接近的过程。相反,我想明确告诉应用程序使用特定资源字典中的资源。非常感谢任何帮助。

I want to have several resource dictionaries in my application and access a resource defined in a particular resource dictionary. Is this possible? According to what I have read, the looking up for a particular key is a native process and we don't have a control over it. In fact, I will have the same key for several resources in different resource dictionaries. If I go with the current procedure only the one which is closest in the hierarchy tree will be used. Instead I want to tell the application explicitly to use a resource in a specific resource dictionary. Any help is much appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

长途伴 2024-10-20 12:32:11

应该做的是在单独的 xaml 文件中按照您想要的方式定义资源字典,并在需要时将它们添加到源属性下(当然您可以通过 C# 代码执行此操作)。那么无论你是否拥有相同的密钥都不会出现问题,只会使用引用的xaml作为资源的提供者。

What should be done is to define the resource dictionaries the way you want in separate xaml files and add them under the source property when needed (of course you can do this via C# code). Then it won't be a problem whether you have the same key or not, only the referred xaml will be used as the provider of resources.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文