C# 在共享文件夹中找不到Visual Studio Universal App资源

C# 在共享文件夹中找不到Visual Studio Universal App资源,c#,visual-studio,xaml,windows-phone-8.1,win-universal-app,C#,Visual Studio,Xaml,Windows Phone 8.1,Win Universal App,这个问题主要困扰一些人,因为VisualStudioIDE告诉我它找不到资源,但是当我构建应用程序时,我没有任何问题 在我的Visual Studio中,我有: 下面是我的通用应用程序架构的一个示例,如下所示: 例如:windowsPhone ->MainPage.xaml 例如,分享 -> Style.xaml -> App.Xaml has Style.xaml referenced 尽管我在我的风格页面中有这样的参考DmBlueBrush: <SolidCo

这个问题主要困扰一些人,因为VisualStudioIDE告诉我它找不到资源,但是当我构建应用程序时,我没有任何问题

在我的Visual Studio中,我有:

下面是我的通用应用程序架构的一个示例,如下所示:

例如:windowsPhone

->MainPage.xaml
例如,分享

-> Style.xaml
-> App.Xaml has Style.xaml referenced
尽管我在我的风格页面中有这样的参考DmBlueBrush:

 <SolidColorBrush x:Key="DmBlueBrush" Color="{StaticResource DmBlue}" />

在VisualStudio中,它会告诉我它找不到它,但是当我构建应用程序时,它会找到这个资源。我没有正确地引用IDE工作所需的内容吗

我正在使用Visual Studio 2013专业版12.0.31101.00更新4

编辑1:

在共享的App.xaml中,我有:

<Application
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="Theme/Styles.xaml"/>
                <ResourceDictionary Source="Theme/Other.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>
</Application>

您是否链接了资源字典

右键单击共享项目>添加>新建项>资源字典

对于本例,将其命名为MyStyles.xaml

<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:YOUR_CLASS">
    <SolidColorBrush x:Key="MyGreen" Color="Green"/>    
</ResourceDictionary>
然后在App.xaml中通过



示例MyStyles.xaml

<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:YOUR_CLASS">
    <SolidColorBrush x:Key="MyGreen" Color="Green"/>    
</ResourceDictionary>

问题在于,您需要直接从另一个ResourceDictionary内部合并ResourceDictionary,而不是将它们都包含在App.xaml中

有关完整示例,请参见此处:

是,样式xaml文件在位于共享文件夹中的App.xaml文件中引用folder@Damien嗯,你最好的办法是做一个干净的解决方案->重建。我创建了一个空白的通用项目/两个样式文件,并且能够引用我想要作为静态资源的任何
x:Key
。尝试一个空白的通用项目,看看是否有帮助。如果是这样,那么找出默认空白与您的项目有什么不同。