ComponentResourceKey 建構函式

定義

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

多載

ComponentResourceKey()

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

ComponentResourceKey(Type, Object)

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

ComponentResourceKey()

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

public:
 ComponentResourceKey();
public ComponentResourceKey ();
Public Sub New ()

備註

無參數建構函式通常不會使用,因為 TypeInTargetAssembly 需要值和 ResourceId 值才能進行適當的初始化。 無參數建構函式主要是支援具名參數形式中的 ComponentResourceKey 標記延伸 XAML 使用方式。

適用於

ComponentResourceKey(Type, Object)

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

public:
 ComponentResourceKey(Type ^ typeInTargetAssembly, System::Object ^ resourceId);
public ComponentResourceKey (Type typeInTargetAssembly, object resourceId);
new System.Windows.ComponentResourceKey : Type * obj -> System.Windows.ComponentResourceKey
Public Sub New (typeInTargetAssembly As Type, resourceId As Object)

參數

typeInTargetAssembly
Type

可定義資源索引鍵的型別。

resourceId
Object

唯一識別項,用來將這個 ComponentResourceKeytypeInTargetAssembly 型別的其他相關聯索引鍵相區別。

範例

下列範例會建立 , ComponentResourceKey 然後公開為控制項類別的靜態索引鍵,以提供樣式自訂進入點。

public static ComponentResourceKey ViewBoxStyleKey =
    new ComponentResourceKey(typeof(MyAssemblyResources), "part_ViewBox");
Public Shared ViewBoxStyleKey As New ComponentResourceKey(GetType(MyAssemblyResources), "part_ViewBox")

備註

此建構函式存在於兩個案例中,第一個案例是最重要的案例:

適用於