C# VS2012:查找资源字典时出错

C# VS2012:查找资源字典时出错,c#,xaml,windows-phone-8,C#,Xaml,Windows Phone 8,我正在处理一个Windows Phone 8项目,该项目是使用C Windows Phone Blank App从模板创建的,我添加了一个名为GPResources.xaml的简单资源字典手动创建,然后在App.xaml中引用该文件,我创建的文件位于根文件夹中,代码如下: <!-- VS2012 saying FontFamily and FontSize properties are not recognized or are not accessable, not sure why..

我正在处理一个Windows Phone 8项目,该项目是使用C Windows Phone Blank App从模板创建的,我添加了一个名为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:

VS2012一直给我错误:在App.xaml文件中查找资源字典时出错,我想不出问题出在哪里,有人能给我指出正确的方向吗


干杯

我认为你用错误的方式创建了资源字典。下面是一个示例,介绍如何定义名为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>

您拥有的GPResources.xaml内容的总体结构应该与上面的示例结构类似。这是我找到的解释ResourceDictionary的资源之一,您可能想看一看:

Hi Har07,似乎是的,谢谢您提供的信息,显然我是XAML新手。Cheers@SeanRyan考虑一下,如果你看到它的帮助,建议在这个网站。欢迎来到StackOverflow!!:
<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>