在WPF应用程序中找不到资源字典 [英] Cannot find resource dictionary in WPF application
问题描述
我在建立一个WPF应用程序的过程,并试图引用资源字典时,遇到了一个错误。里面我的WPF应用程序项目我有一个名为样式文件夹包含所有我的应用程序的XAML样式模板:
I'm in the process of building a WPF application and ran into an error when trying to reference a resource dictionary. Inside my WPF application project I have a folder called "Styles" to contain all the xaml style templates for my app:
在我的App.xaml文件我有这样的:
In my app.xaml file I have this:
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Styles/MetroTheme.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
然而,当我将鼠标悬停在源属性,我得到一个错误说,而找到出错资源字典样式/ MetroTheme.xaml我可以看到无论是在Visual Studio中,并在文件系统中的文件夹中的XAML文件。
However, when I hover over the source property I get an error saying "An error occurred while finding the resource dictionary "Styles/MetroTheme.xaml". I can see the xaml file inside the folder both in Visual Studio and in the file system.
我也尝试/样式/ MetroTheme.xaml和源属性包URI,都没有成功。任何想法,为什么我得到这个文件未找到错误?
I have also tried "/Styles/MetroTheme.xaml" and a pack uri for the source property, both with no success. Any idea why I'm getting this file not found error?
推荐答案
请确保为MetroTheme.xaml构建操作设置为页
Make sure that the build action for MetroTheme.xaml is set to Page.
这篇关于在WPF应用程序中找不到资源字典的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!