2015-04-14 57 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'。嘗試一個空白的通用項目,看看是否有幫助。如果是這樣,那麼找出與默認空白與您的項目不同的地方。 –

相關問題