如何在App.xaml中添加资源字典的引用? [英] How to add a reference of Resource Dictionary in App.xaml?

查看:445
本文介绍了如何在App.xaml中添加资源字典的引用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在项目中添加了自己的资源字典 QSStyles.xam l。但是我无法在我的App.xaml中引用该字典。我得到了一个
例如"无法激活Windows应用商店应用"等异常。  解决方案是什么?

I have added my own resource dictionary named QSStyles.xaml in my project. But I am not able to reference that dictionary in my App.xaml.I am getting an exception such as "Unable to activate Windows Store App"  what is the solution?

  App.xaml:<应用程序。资源>

       
< ResourceDictionary>

           
< ResourceDictionary.MergedDictionaries>
$


        &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;
<! -

              &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;定义平台外观的常见问题和感觉

&NBSP风格;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP; Visual Studio项目和项目模板所需的内容

                 - > <跨度>

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;
< ResourceDictionary 来源 = " Common / StandardStyles。 XAML" <跨度> /> <跨度>

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP;
< ResourceDictionary 来源 = " Common / QSStyles.xaml " /> 

         ;&NBSP;&NBSP;&NBSP;
< /ResourceDictionary.MergedDictionaries>





 App.xaml :<Application. Resources>
       
<ResourceDictionary>
           
<ResourceDictionary.MergedDictionaries>

               
<!--
                    Styles that define common aspects of the platform look and feel
                    Required by Visual Studio project and item templates
                 -->

               
<ResourceDictionary Source="Common/StandardStyles.xaml"/>
               
<ResourceDictionary Source="Common/QSStyles.xaml"/> 
           
</ResourceDictionary.MergedDictionaries>


推荐答案

嗨MythriM,

Hi MythriM,

这是没有错的您在上面提供的代码,使用它我可以成功使用QSStyles.xaml文件中的自定义样式。让我们对您的问题进行进一步的故障排除:

There is nothing wrong with the code you offered above, with it I can successfully use the custom styles in the QSStyles.xaml file. Let's do further troubleshooting of your issue:

1)。请先检查您的问题是否与QSStyles.xaml文件有关。因此,如果您注释掉行< ResourceDictionary Source =" Common / QSStyles.xaml" />,您会得到相同的例外吗?

2)。还要确保QSStyles.xaml文件中没有任何错误。如果在该文件中添加非常简单的样式定义,是否会存在相同的异常?

1). Please first check whether your issue is related to the QSStyles.xaml file. So, if you comment out line <ResourceDictionary Source="Common/QSStyles.xaml"/>, will you get the same exception?
2). Also make sure there is nothing wrong in the QSStyles.xaml file. If you add very simple style definition in that file, will the same exception exists?

谢谢。


这篇关于如何在App.xaml中添加资源字典的引用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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