ComponentResourceKey 類別

定義

基於外部組件 (Assembly) 中的類別 (Class) 名稱與其他識別項定義或參照資源索引鍵。

public ref class ComponentResourceKey : System::Windows::ResourceKey
[System.ComponentModel.TypeConverter(typeof(System.Windows.Markup.ComponentResourceKeyConverter))]
public class ComponentResourceKey : System.Windows.ResourceKey
[<System.ComponentModel.TypeConverter(typeof(System.Windows.Markup.ComponentResourceKeyConverter))>]
type ComponentResourceKey = class
    inherit ResourceKey
Public Class ComponentResourceKey
Inherits ResourceKey
繼承
ComponentResourceKey
屬性

備註

如需 XAML 資訊,請參閱 ComponentResourceKey 標記延伸

這個類別會實作物件類型,這個類型適用于建立以元件中的類型加上識別碼為基礎的索引鍵。 由於您定義或參考類型,因此您不需要要求特定 ResourceDictionary ,而且元件中可以存在一組以上的資源,每個資源都依其 ComponentResourceKey 類型區分。

有兩種方式可以定義 ComponentResourceKey

如果您想要容易存取的索引鍵,您可以在控制項類別程式碼上定義靜態屬性,此程式碼會傳回 ComponentResourceKey 、使用存在於外部資源元件中的 和 ResourceId 所建構 TypeInTargetAssembly 的 。 索引鍵可用來定義元件中控制項的替代預設樣式,方法是交換自訂群組件的原始外部資源元件。 您也可以在較大的控制項樣式或範本內定義具名資源元件,以公開自訂進入點。 如果您要為控制項定義主題資源字典,這特別有用。

您也可以直接在詳細資訊語法中使用 XAML ComponentResourceKey 標記延伸 ,以建立索引鍵的鬆散實例。 如果您想要從其他無法探索到的元件宣告私人資源,這會很有用。

建構函式

ComponentResourceKey()

初始化 ComponentResourceKey 類別的新執行個體。

ComponentResourceKey(Type, Object)

初始化 類別的新實例 ComponentResourceKey ,並 Type 指定要定義索引鍵的 ,以及要當做其他資源識別碼使用的 物件。

屬性

Assembly

取得組件物件,這個物件表示在哪個組件字典中尋找與這個索引鍵相關聯的值。

ResourceId

取得或設定唯一識別項,以將這個索引鍵與這個型別的其他相關聯索引鍵相區別。

TypeInTargetAssembly

取得或設定可定義資源索引鍵的 Type

方法

Equals(Object)

判斷提供的物件和目前的 ComponentResourceKey 是否相等。

GetHashCode()

傳回這個 ComponentResourceKey 的雜湊碼。

GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ProvideValue(IServiceProvider)

傳回這個 ResourceKey。 這個類別的執行個體通常會當做字典中的索引鍵來使用。

(繼承來源 ResourceKey)
ToString()

取得 ComponentResourceKey 的字串表示。

適用於