Note

Access to this page requires authorization. You can try signing in or .

Access to this page requires authorization. You can try .

ComponentResourceKey Constructors

Definition

Namespace:
System.Windows
Assembly:
PresentationFramework.dll

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Initializes a new instance of the ComponentResourceKey class.

Overloads

Name Description
ComponentResourceKey()

Initializes a new instance of the ComponentResourceKey class.

ComponentResourceKey(Type, Object)

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

ComponentResourceKey()

Initializes a new instance of the ComponentResourceKey class.

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

Remarks

The parameterless constructor is not generally used, because a TypeInTargetAssembly value and ResourceId value are required for proper initialization. The parameterless constructor exists primarily to support ComponentResourceKey Markup Extension XAML usage in named parameter form.

Applies to

ComponentResourceKey(Type, Object)

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

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)

Parameters

typeInTargetAssembly
Type

The type that defines the resource key.

resourceId
Object

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

Examples

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");
Public Shared ViewBoxStyleKey As New ComponentResourceKey(GetType(MyAssemblyResources), "part_ViewBox")

Remarks

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.

Applies to


Feedback

Was this page helpful?