Export (0) Print
Expand All

ComponentResourceKey Constructor (Type, Object)

Initializes a new instance of a ComponentResourceKey , specifying the Type that defines the key, and an object to use as an additional resource identifier.

Namespace:  System.Windows
Assembly:  PresentationFramework (in PresentationFramework.dll)

public ComponentResourceKey(
	Type typeInTargetAssembly,
	Object resourceId
)

Parameters

typeInTargetAssembly
Type: System.Type

The type that defines the resource key.

resourceId
Type: System.Object

A unique identifier to differentiate this ComponentResourceKey from others associated with the typeInTargetAssembly type.

This constructor exist for two scenarios, with the first scenario being the most important:

  • Supports creating a ComponentResourceKey that is then exposed as a public static field on a custom control class. This simplifies a control's access to its own defined resources in the template through {x:Static} usages for template property values.

  • Supports ComponentResourceKey Markup Extension XAML usage in positional parameter form, which is one technique available for third parties that reference a component resource.

The following example creates a ComponentResourceKey that is then exposed as a static key of a control class to provide a style customization entry point.

public static ComponentResourceKey ViewBoxStyleKey =
    new ComponentResourceKey(typeof(MyAssemblyResources), "part_ViewBox");

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft