2013-05-22 29 views
2

我有一个简单的样式在位于WPFResources.dll的资源字典中,我正在访问另一个项目中的样式,我可以看到风格正在设计时应用,但是当我运行应用程序时,我得到一个异常,即"Cannot find resource named 'IndentCheckBoxStyle'. Resource names are case sensitive"。如果我使用StaticResource,那么我可以看到这个异常,如果我使用DynamicResource,那么我没有看到任何异常,但没有任何可见的用户界面。风格是不是在运行时应用,但在设计时应用于WPF

更多关于这个问题:

我已经在我的项目在App.xaml中引用的WPFResources.dll和合并像这样:

<Application.Resources> 
    <ResourceDictionary> 
    <ResourceDictionary.MergedDictionaries> 
       <ResourceDictionary Source="/WPFResources;component/Theme.xaml" /> 
     </ResourceDictionary.MergedDictionaries>   
    </ResourceDictionary> 
    </Application.Resources> 

而且Theme.xaml里面我已经合并cheboxstyle的资源字典。

任何人有任何想法?

在此先感谢。

+0

你如何发布相关的代码? – DHN

+0

WPFResources.dll在应用程序bin路径中是否可用? – sthotakura

+0

是的,它是在绑定文件夹中,我已经在App.XAML中添加了 – user2408987

回答

1

我有这个问题,发现风格都被应用到使用包URI语法的整个应用程序,

例如在App.xaml中

<Application x:Class="Framework.Presentation.Preview.App" 
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
      StartupUri="MainWindow.xaml"> 
    <Application.Resources> 
     <ResourceDictionary> 
      <ResourceDictionary.MergedDictionaries> 
       <ResourceDictionary Source="pack://application:,,,/Abt.Framework.Presentation;component/Themes/AbtDark.xaml"/> 
      </ResourceDictionary.MergedDictionaries> 
     </ResourceDictionary> 
    </Application.Resources> 
</Application> 

然而,一个隐含的风格不被应用到应用程序中的顶层窗口(尽管MyTheme.xaml包含窗口未命名的样式)

要解决此,我我只是使用了一个命名风格(而不是隐式风格)的窗口。其余的都正确应用。

相关问题