简体   繁体   English

VS2012:查找资源字典时发生错误

[英]VS2012: An Error occurred while finding the resource dictionary

I am working on a Windows Phone 8 project, project was created using C# Windows Phone Blank App from templates, I have added a simple ResourceDictionary entitled GPResources.xaml(manually created) and then referenced that file in App.xaml, the file I created is located in the root folder, code below: 我正在处理Windows Phone 8项目,该项目是使用C#Windows Phone空白应用程序通过模板创建的,我添加了一个简单的ResourceDictionary,名为GPResources.xaml(手动创建),然后在App.xaml中引用了该文件,即我创建的文件位于根文件夹中,代码如下:

<!-- VS2012 saying FontFamily and FontSize properties are not recognized or are not accessable, not sure why... ANYONE?-->

<Style TargetType="{StaticResource GPFontFamily}">
    <Setter Property="FontFamily" Value="CalifR.ttf"/>   
</Style>

<Style TargetType="{StaticResource GPFontSizeSmall}">
    <Setter Property="FontSize" Value="12"/>
</Style>

<Style TargetType="{StaticResource GPFontSizeMedium}">
    <Setter Property="FontSize" Value="18"/>
</Style>

<Style TargetType="{StaticResource GPFontSizeLarge}">
    <Setter Property="FontSize" Value="22"/>
</Style>

App.Xaml: App.xaml中:

    <ResourceDictionary x:Key="GPResources">
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="GPResources.xaml"/>
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>

</Application.Resources>

VS2012 keeps giving me the error: "An Error occurred while finding the resource dictionary" in the App.xaml file, I cannot think of what the problem is, can anyone point me in the right direction? VS2012一直给我错误:App.xaml文件中“在查找资源字典时发生错误”,我想不出是什么问题,有人能指出我正确的方向吗?

Cheers 干杯

I think you created Resource Dictionary in a wrong way. 我认为您以错误的方式创建了资源字典。 Following is an example on how to define a style named " GPTextBlock " that will style a TextBlock where it applied, to have a FontSize = 12 and displaying text in Red color. 以下是有关如何定义名为“ GPTextBlock ”的样式的示例,该样式将对应用的TextBlock进行样式设置,以使FontSize = 12并以红色显示文本。

<ResourceDictionary
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Style TargetType="TextBlock" x:Key="GPTextBlock">
        <Setter Property="Foreground" Value="Red"/>
        <Setter Property="FontSize" Value="12"/>
    </Style>
    <Style ...>
        ...
        ...
    </Style>
    ....
    ....
</ResourceDictionary>

And overall structure of GPResources.xaml content you had should look like above sample structure. 您拥有的GPResources.xaml内容的总体结构应类似于上面的示例结构。 This is one of resources I found explaining about ResourceDictionary you may want to take a look : MSDN Blog 这是我发现的有关ResourceDictionary的资源之一,您可能想看看: MSDN博客

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 WPF VS2013:查找资源字典时发生错误 - WPF VS2013: An error occurred while finding the resource dictionary VS2013:查找资源字典时发生错误/类型不是名称空间的一部分 - VS2013: An error occurred while finding the resource dictionary / Type is not part of namespace 无法连接到VS2012中的localDB - “建立与SQL Server的连接时发生与网络相关或特定于实例的错误...” - Unable to connect to localDB in VS2012 – “A network-related or instance-specific error occurred while establishing a connection to SQL Server…” 在VS2012中读取任何WPF项目的资源文件时出错 - Error Reading Resource File for any WPF Project in VS2012 在VS2012中构建解决方案时出现ALINK错误 - ALINK Error while Building the Solution in VS2012 无法在VS2012中创建资源文件 - Not able to create resource file in VS2012 VS2012无法解析资源“X” - VS2012 The resource “X” could not be resolved Vs2017:查找带有组件标签的资源字典时发生错误 - Vs2017: An Error Occured while finding the resource dictionary with component tagged VS2012中的项目链接器安装错误 - Project linker installation error in VS2012 加载资源字典时出错 - Error Occurred Loading Resource Dictionary
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM