2010-04-19 28 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中的位置。