2010-04-19 74 views
3

我有XAMLWPF 4:MergedDictionaries似乎不工作了

引用在設計時這項工作
'BaseStyles.xaml 
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> 

    <ResourceDictionary.MergedDictionaries> 
     <ResourceDictionary Source="ShinyBlue.xaml"/> 
     <ResourceDictionary Source="DataGrid.Generic.xaml"/> 
    </ResourceDictionary.MergedDictionaries> 

</ResourceDictionary> 

形式下面的框,而不是在運行時間。 如果我的表單直接引用ShinyBlue.xaml或DataGrid.Generic.xaml,則該樣式表工作。

編輯

如果我直接粘貼到這個形式,它工作正常。顯然這個問題與我的包裝有關。

破碎

<Window.Resources> 
    <ResourceDictionary Source="../BaseStyles.xaml"/> 
</Window.Resources> 

作品

<ResourceDictionary.MergedDictionaries> 
    <ResourceDictionary Source="ShinyBlue.xaml"/> 
    <ResourceDictionary Source="DataGrid.Generic.xaml"/> 
</ResourceDictionary.MergedDictionaries> 
+0

它似乎在WPF 4中對我來說工作得很好......你能提供一個簡化版本的項目嗎? – Brent 2010-04-26 12:53:15

回答

2

嘗試包括你的整個路徑從命名空間中的文件名:

<ResourceDictionary Source="pack://application:,,,/[YourDll];component/[YourLocation]/ShinyBlue.xaml"/> 

其中[YourDll]是你的項目名稱,[ YourLocation]是ResourceDictionary駐留在dll中的位置。