[英]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.