本文介绍了什么是对ThemeInfo属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当我创建一个新的WPF应用程序或WPF用户控件库,在的AssemblyInfo.cs 文件包含以下属性:

Whenever I create a new WPF application or WPF user control library, the AssemblyInfo.cs file includes the following attribute:

[assembly: ThemeInfo(
    ResourceDictionaryLocation.None, 
    //where theme specific resource dictionaries are located
    //(used if a resource is not found in the page, 
    // or application resource dictionaries)
    ResourceDictionaryLocation.SourceAssembly 
    //where the generic resource dictionary is located
    //(used if a resource is not found in the page, 
    // app, or any theme specific resource dictionaries)
)]

,这是什么 ThemeInfo 属性?我将打破任何东西,如果我删除它?

What is this ThemeInfo attribute for? Will I break anything if I remove it?

推荐答案

ThemeInfo属性指定了自动主题化机制,应该寻找主题字典和通用字典。每个选项可以设置为以下值之一:

ThemeInfo attribute specifies where the automatic theming mechanism should look for the theme dictionaries and the generic dictionary. Each option can be set to one of the following values:


  • 无(默认):不要找一个资源字典

  • SourceAssembly:这本词典是目前组装

  • ExternalAssembly:这本词典是在不同的组件,它必须被命名为
    <的AssemblyName方式>< THEMENAME>的.dll ,其中<的AssemblyName> 是当前装配的
    名称。

  • None (default): Don’t look for a resource dictionary.
  • SourceAssembly: The dictionary is the current assembly.
  • ExternalAssembly: The dictionary is in a different assembly, which must be named <AssemblyName>.<ThemeName>.dll, where <AssemblyName> is the current assembly's name.

如果主题字典指定在外部组件中定义的,例如控制样式,WPF的控制,如 System.Windows.Controls.ProgressBar System.Windows.Button ,则必须使用 ThemeDictionaryExtension 来指定应用程序的来源为主题的字典。

If the theme dictionaries specify styles for controls that are defined in external assemblies, for example, the WPF controls such as System.Windows.Controls.ProgressBar and System.Windows.Button, then you must use the ThemeDictionaryExtension to specify the application as the source for the theme dictionaries.

这篇关于什么是对ThemeInfo属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-14 23:37