如何将 PresentationFramework.Aero 主题添加到 ResourceDictionary [英] How to add PresentationFramework.Aero theme to ResourceDictionary

查看:56
本文介绍了如何将 PresentationFramework.Aero 主题添加到 ResourceDictionary的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I want to add the PresentationFramework.Aero theme to my ResourceDictionary. The ResourceDictionary itself is in one assembly called ProjectResources. Within this assembly I define all my styles for my project. So this ResourceDictionary is used by several different assemblies in my project. So far it worked fine for all my Dictionaries defined.

现在我想添加 Aero 主题.但我总是得到例外:

Now i want to add the Aero theme. But I always get the exception:

未处理的异常类型'System.Windows.Markup.XamlParseException' 发生在演示框架.dll

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

内部异常:

{"无法加载文件或程序集'PresentationFramework.Aero,Culture=neutral' 或其依赖项之一.系统找不到指定的文件.":"PresentationFramework.Aero, Culture=neutral"}

{"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 定义如下:

The ResourceDictionary is defined like that:

<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 的引用.

I have also added the reference to PresentationFramework.Aero.dll.

所以我不明白为什么它找不到定义的主题.这个定义有什么问题?为了能够使用主题,除了这个定义之外,我还有什么遗漏吗?

So I don't understand why it cant find the defined theme. What is the problem with this definition? Did I miss anything else beside this definition to be able to use the theme?

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

SOLVED: As toumir said in his comment. You need to set the parameter

复制本地 = 真

PresentationFramework.Aero DLL.通过这样做,dll 将被复制到您程序的根目录中,它会复制 dll.

of the PresentationFramework.Aero DLL. By doing that the dll will be copied to the root directory of your program and it will the dll.

推荐答案

我认为您需要将完整的程序集信息添加到 ResourceDictionary 来源:

I think you need to add the full assembly info to the ResourceDictionary Source:

<ResourceDictionary Source="/PresentationFramework.Aero,Version=3.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35,processorArchitecture=MSIL;component/themes/Aero.NormalColor.xaml" />

这篇关于如何将 PresentationFramework.Aero 主题添加到 ResourceDictionary的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆