gpt4 book ai didi

c# - 如何将 PresentationFramework.Aero 主题添加到 ResourceDictionary

转载 作者:太空宇宙 更新时间:2023-11-03 15:32:22 25 4
gpt4 key购买 nike

我想将 PresentationFramework.Aero 主题添加到我的 ResourceDictionary。ResourceDictionary 本身位于一个名为 ProjectResources 的程序集中。在这个程序集中,我为我的项目定义了我的所有样式。所以这个 ResourceDictionary 被我项目中的几个不同的程序集使用。到目前为止,它适用于我定义的所有词典。

现在我想添加 Aero 主题。但我总是得到异常(exception):

An unhandled exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll

内部异常:

{"Could not load file or assembly 'PresentationFramework.Aero, Culture=neutral' or one of its dependencies. The system cannot find the file specified.":"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 的引用。

所以我不明白为什么它找不到定义的主题。这个定义有什么问题?为了能够使用主题,我是否错过了除此定义之外的任何其他内容?

已解决:正如图米尔在他的评论中所说。您需要设置参数

Copy Local = true

PresentationFramework.Aero 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" />

关于c# - 如何将 PresentationFramework.Aero 主题添加到 ResourceDictionary,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33386220/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com