如何将PresentationFramework.Aro主题添加到ResourceDictionary
本文关键字:添加 ResourceDictionary Aro PresentationFramework | 更新日期: 2023-09-27 18:19:31
我想将PresentationFramework.Aro主题添加到我的ResourceDictionary中。ResourceDictionary本身位于一个名为ProjectResources的程序集中。在这个程序集中,我定义了我的项目的所有样式。因此,这个ResourceDictionary被我的项目中的几个不同的程序集使用。到目前为止,它适用于我定义的所有词典。
现在我想添加Aero主题。但我总是得到一个例外:
类型为的未处理异常中发生"System.Windows.Markup.XamlParseException"PresentationFramework.dll
内部异常:
{"无法加载文件或程序集"PresentationFramework.Aero,"区域性=中性"或其依赖项之一。系统找不到指定的文件。":"PresentationFramework.Aero,Culture=neutral"}
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.Aro DLL的。通过这样做,dll将被复制到程序的根目录,它将成为dll。
我认为您需要将完整的程序集信息添加到ResourceDictionary Source:
<ResourceDictionary Source="/PresentationFramework.Aero,Version=3.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35,processorArchitecture=MSIL;component/themes/Aero.NormalColor.xaml" />