ComponentResourceKey Class
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.
Defines or references resource keys based on class names in external assemblies, as well as an additional identifier.
public ref class ComponentResourceKey : System::Windows::ResourceKey
[System.ComponentModel.TypeConverter(typeof(System.Windows.Markup.ComponentResourceKeyConverter))]
public class ComponentResourceKey : System.Windows.ResourceKey
[<System.ComponentModel.TypeConverter(typeof(System.Windows.Markup.ComponentResourceKeyConverter))>]
type ComponentResourceKey = class
inherit ResourceKey
Public Class ComponentResourceKey
Inherits ResourceKey
- Inheritance
- Attributes
For XAML information, see ComponentResourceKey Markup Extension.
This class implements an object type that is useful for creating keys that are based on types in assemblies plus an identifier. Because you define or reference the type, you do not need to request a specific ResourceDictionary, and more than one set of resources can exist in the assembly, each differentiated by the type of their ComponentResourceKey.
There are two ways to define a ComponentResourceKey.
If you want an easily accessible key, you can define a static property on your control class code that returns a ComponentResourceKey, constructed with a TypeInTargetAssembly that exists in the external resource assembly, and a ResourceId. The key can be used for defining alternate default styles for controls in an assembly, by swapping the original external resource assembly for a custom one. You can also define a named resource part within a larger control style or template to expose a customization entry point. This is particularly useful if you are defining a theme resource dictionary for your control.
You can also use the XAML ComponentResourceKey Markup Extension in verbose syntax directly to create a loose instance of the key. This is useful if you want to declare private resources from other assemblies that are less discoverable to customize.
Component |
Initializes a new instance of the ComponentResourceKey class. |
Component |
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. |
Assembly |
Gets the assembly object that indicates which assembly's dictionary to look in for the value associated with this key. |
Resource |
Gets or sets a unique identifier to differentiate this key from others associated with this type. |
Type |
Gets or sets the Type that defines the resource key. |
Equals(Object) |
Determines whether the provided object is equal to the current ComponentResourceKey. |
Get |
Returns a hash code for this ComponentResourceKey. |
Get |
Gets the Type of the current instance. (Inherited from Object) |
Memberwise |
Creates a shallow copy of the current Object. (Inherited from Object) |
Provide |
Returns this ResourceKey. Instances of this class are typically used as a key in a dictionary. (Inherited from ResourceKey) |
To |
Gets the string representation of a ComponentResourceKey. |
Product | Versions |
---|---|
.NET Framework | 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
Windows Desktop | 3.0, 3.1, 5, 6, 7, 8, 9 |
.NET feedback
.NET is an open source project. Select a link to provide feedback: