我想将PresentationFramework.Aero主题添加到我的ResourceDictionary中。
ResourceDictionary本身位于一个名为ProjectResources的程序集中。在此程序集中,我为项目定义了所有样式。因此,该ResourceDictionary被我项目中的多个不同程序集使用。到目前为止,它对我定义的所有“字典”都有效。
现在,我想添加Aero主题。但我总是得到一个例外:
类型的未处理异常
“ System.Windows.Markup.XamlParseException”发生在
PresentationFramework.dll
内部异常:
{“无法加载文件或程序集'PresentationFramework.Aero,
文化=中立”或其中之一。系统找不到
指定的文件。“:” PresentationFramework.Aero,文化=中性“}
ResourceDictionary的定义如下:
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/ProjectResources;component/ProjectResources/Dictionaries/ImageDefinition.xaml"/>
<ResourceDictionary Source="pack://application:,,,/ProjectResources;component/ProjectResources/Dictionaries/Brushes.xaml"/>
<ResourceDictionary Source="pack://application:,,,/ProjectResources;component/ProjectResources/Dictionaries/StylesLabel.xaml"/>
<ResourceDictionary Source="pack://application:,,,/ProjectResources;component/ProjectResources/Dictionaries/StylesTextBox.xaml"/>
<ResourceDictionary Source="pack://application:,,,/ProjectResources;component/ProjectResources/Dictionaries/StylesButton.xaml"/>
<ResourceDictionary Source="pack://application:,,,/ProjectResources;component/ProjectResources/Dictionaries/StylesTabControl.xaml"/>
<ResourceDictionary Source="pack://application:,,,/ProjectResources;component/ProjectResources/Dictionaries/StylesTextBox.xaml"/>
<ResourceDictionary Source="pack://application:,,,/ProjectResources;component/ProjectResources/Dictionaries/StylesBorder.xaml"/>
<ResourceDictionary Source="pack://application:,,,/ProjectResources;component/ProjectResources/Dictionaries/StylesListView.xaml"/>
<ResourceDictionary Source="pack://application:,,,/ProjectResources;component/ProjectResources/Dictionaries/StylesWindow.xaml"/>
<ResourceDictionary Source="pack://application:,,,/ProjectResources;component/ProjectResources/Dictionaries/StylesIndicator.xaml"/>
<ResourceDictionary Source="pack://application:,,,/ProjectResources;component/ProjectResources/Dictionaries/StylesSearchBox.xaml"/>
<ResourceDictionary Source="pack://application:,,,/ProjectResources;component/ProjectResources/Dictionaries/StylesTreeView.xaml"/>
<ResourceDictionary Source="/PresentationFramework.Aero;component/themes/Aero.NormalColor.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
我还添加了对PresentationFramework.Aero.dll的引用。
所以我不明白为什么找不到所定义的主题。
这个定义有什么问题?除了定义之外,我是否还想使用主题?
解决了:
正如图米尔在评论中所说。
您需要设置参数
复制本地=真
PresentationFramework.Aero DLL。
这样,该dll将被复制到您程序的根目录,并且它将成为dll。
最佳答案
我认为您需要将完整的程序集信息添加到ResourceDictionary源:
<ResourceDictionary Source="/PresentationFramework.Aero,Version=3.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35,processorArchitecture=MSIL;component/themes/Aero.NormalColor.xaml" />
关于c# - 如何将PresentationFramework.Aero主题添加到ResourceDictionary,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/33386220/