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

属性值

定义资源键的类型。

示例

以下示例演示如何定义 ComponentResourceKey 包含 TypeInTargetAssembly 和使用 ResourceIdComponentResourceKey 标记扩展。 然后,此资源可以放置在外部程序集中,并通过使用请求中的类似方式 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类型。

适用于