Share via


ComponentResourceKey.TypeInTargetAssembly 屬性

定義

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

public:
 property Type ^ TypeInTargetAssembly { Type ^ get(); void set(Type ^ value); };
public Type TypeInTargetAssembly { get; set; }
member this.TypeInTargetAssembly : Type with get, set
Public Property TypeInTargetAssembly As Type

屬性值

Type

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

範例

下列範例示範如何定義 ComponentResourceKey 包含 TypeInTargetAssembly 和使用 ResourceId ComponentResourceKey 標記延伸。 然後,此資源可以放在外部元件中,並透過金鑰使用方式來要求資源,並在要求中使用類似的 ComponentResourceKey 方式來存取。

<Style 
    x:Key="{ComponentResourceKey 
        TypeInTargetAssembly={x:Type local:ColorPicker},
        ResourceId=ColorSliderStyle}"
    TargetType="{x:Type Slider}">

    <Setter Property="Minimum" Value="0"/>
    <Setter Property="Maximum" Value="255"/>
    <Setter Property="SmallChange" Value="1"/>
    <Setter Property="LargeChange" Value="51"/>
    <Setter Property="IsMoveToPointEnabled" Value="true"/>
    <Setter Property="Orientation" Value="Horizontal"/>
</Style>

備註

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

自訂 ComponentResourceKey 元件會使用 元素,根據以包含型別的元件為目標,定義從外部元件存取之資源的索引鍵。 自訂群組件通常會定義新的類型,這些類型必須位於資源所在的元件中。 一般而言,這些類型沒有其他實作,只有型別才存在,才能滿足 的 ComponentResourceKey 查閱需求。

適用於