ThemeInfoAttribute 类

定义

指定为程序集存储主题字典的位置。

public ref class ThemeInfoAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Assembly)]
public sealed class ThemeInfoAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Assembly)>]
type ThemeInfoAttribute = class
    inherit Attribute
Public NotInheritable Class ThemeInfoAttribute
Inherits Attribute
继承
ThemeInfoAttribute
属性

注解

此属性用于程序集级别,以指示程序集为其定义的控件以及资源字典所在的位置声明哪个主题资源字典。

例如,如果未提供特定于主题的资源字典,并且 generic.xaml 为所有资源查找提供资源定义的程序集编译为程序集的控件类定义所在的同一程序集,则在程序集项目中应用以下属性 AssemblyInfo.cs

[assembly:ThemeInfoAttribute(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)]

除了 ThemeInfoAttribute 应用程序之外,项目和程序集还必须具有其他特征,以便资源字典可供WPF主题系统使用。

  • 如果声明 SourceAssembly,则引用的资源字典应放置在 themes 程序集结构中的目录中。

  • 如果声明 SourceAssemblyThemeDictionaryLocation则 XAML 文件的名称应符合 XAML 文件命名方案 themes\<Theme Name>.<Theme Color>.xaml。 例如,下面是支持客户端上各种可能WPF主题方案的主题文件列表:

    • themes\luna.normalcolor.xaml

    • themes\luna.homestead.xaml

    • themes\luna.metallic.xaml

    • themes\royale.normalcolor.xaml

    • themes\aero.normalcolor.xaml

    • themes\classic.xaml

  • 如果声明 ExternalAssembly,则外部程序集名称应符合命名方案,并且每个主题的每个程序集都应使用相同的密钥信息生成。

有关如何创建和使用主题资源字典的详细信息,请参阅主题 控件创作概述的“在主题级别定义资源”部分。

构造函数

名称 说明
ThemeInfoAttribute(ResourceDictionaryLocation, ResourceDictionaryLocation)

初始化类的新实例 ThemeInfoAttribute ,并创建一个属性,该属性定义程序集中类型的主题字典位置。

属性

名称 说明
GenericDictionaryLocation

泛型资源(而不是特定于主题的资源)的位置。

ThemeDictionaryLocation

主题特定资源的位置。

TypeId

在派生类中实现时,获取此 Attribute的唯一标识符。

(继承自 Attribute)

方法

名称 说明
Equals(Object)

返回一个值,该值指示此实例是否等于指定对象。

(继承自 Attribute)
GetHashCode()

返回此实例的哈希代码。

(继承自 Attribute)
GetType()

获取当前实例的 Type

(继承自 Object)
IsDefaultAttribute()

在派生类中重写时,指示此实例的值是否为派生类的默认值。

(继承自 Attribute)
Match(Object)

在派生类中重写时,返回一个值,该值指示此实例是否等于指定对象。

(继承自 Attribute)
MemberwiseClone()

创建当前 Object的浅表副本。

(继承自 Object)
ToString()

返回一个表示当前对象的字符串。

(继承自 Object)

显式接口实现

名称 说明
_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

将一组名称映射为对应的一组调度标识符。

(继承自 Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

检索对象的类型信息,该信息可用于获取接口的类型信息。

(继承自 Attribute)
_Attribute.GetTypeInfoCount(UInt32)

检索对象提供的类型信息接口的数量(0 或 1)。

(继承自 Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

提供对对象公开的属性和方法的访问。

(继承自 Attribute)

适用于