2015-04-14 54 views
7

由于Visual Studio IDE告诉我它无法找到资源,所以此问题主要麻烦一些,但是当生成应用程序时,我没有任何问题。共享文件夹中找不到Visual Studio通用应用程序资源

在我的Visual Studio中我有这样的: enter image description here

这里是我的通用的应用程序体系结构的一个示例如下:

Example.windowsPhone

->MainPage.xaml 

Example.Share

-> Style.xaml 
-> App.Xaml has Style.xaml referenced 

Ev enthought我有一个像这样在我的风格页面引用DmBlueBrush:

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

在Visual Studio它会告诉我,它不能找到它,但是当我构建应用程序就会找到这个资源。我没有正确引用我的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> 

回答

1

你链接您的资源字典?

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

在这个例子中,将其命名为通过

<Application 
    x:Class="YOUR_CLASS.App" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:local="using:YOUR_CLASS"> 
    <Application.Resources> 
     <ResourceDictionary Source="MyStyles.xaml"></ResourceDictionary> 
    </Application.Resources> 
</Application> 
MyStyles.xaml

在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> 
+1

是风格XAML文件是在位于共享文件夹中的App.xaml文件中引用 – Damien

+1

@Damien嗯,你最好的选择,然后做一个干净的解决方案 - >重建。我创建了一个空白的通用项目/两个样式文件,并能够引用任何我想作为静态资源使用的'x:Key'。尝试一个空白的通用项目,看看是否有帮助。如果是这样,那么找出与默认空白与您的项目不同的地方。 –

相关问题