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)

將一組名稱對應至一組對應的分派識別項 (Dispatch Identifier)。

(繼承來源 Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

擷取物件的類型資訊,可以用來取得介面的類型資訊。

(繼承來源 Attribute)
_Attribute.GetTypeInfoCount(UInt32)

擷取物件提供的類型資訊介面數目 (0 或 1)。

(繼承來源 Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

提供物件所公開的屬性和方法的存取權。

(繼承來源 Attribute)

適用於