Windows apps
Collapse the table of content
Expand the table of content
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

ResourceDictionary Class


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Provides a hash table / dictionary implementation that contains WPF resources used by components and other elements of a WPF application. 

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

public class ResourceDictionary : IDictionary, ICollection, IEnumerable, 
	ISupportInitialize, IUriContext, INameScope


Initializes a new instance of the ResourceDictionary class.


Gets the number of entries in the base ResourceDictionary.


This API supports the product infrastructure and is not intended to be used directly from your code. Gets or sets the deferrable content for this resource dictionary.


Gets or sets a value that indicates whether the invalidations fired by the ResourceDictionary object cause ContentPresenter objects to reevaluate their choice of template. The invalidations happen when an implicit data template resource changes.


Gets whether this ResourceDictionary is fixed-size.


Gets whether this ResourceDictionary is read-only.


Gets or sets the value associated with the given key.


Gets a collection of all keys contained in this ResourceDictionary.


Gets a collection of the ResourceDictionary dictionaries that constitute the various resource dictionaries in the merged dictionaries.


Gets or sets the uniform resource identifier (URI) to load resources from.


Gets a collection of all values associated with keys contained in this ResourceDictionary.

System_CAPS_pubmethodAdd(Object, Object)

Adds a resource by key to this ResourceDictionary.


Begins the initialization phase for this ResourceDictionary.


Clears all keys (and values) in the base ResourceDictionary. This does not clear any merged dictionary items.


Determines whether the ResourceDictionary contains an element with the specified key.

System_CAPS_pubmethodCopyTo(DictionaryEntry[], Int32)

Copies the ResourceDictionary elements to a one-dimensional DictionaryEntry at the specified index.


Ends the initialization phase, and invalidates the previous tree such that all changes made to keys during the initialization phase can be accounted for.


Determines whether the specified object is equal to the current object.(Inherited from Object.)


Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)


Not supported by this Dictionary implementation.


Returns an IDictionaryEnumerator that can be used to iterate through the ResourceDictionary.


Serves as the default hash function. (Inherited from Object.)


Gets the Type of the current instance.(Inherited from Object.)


Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_protmethodOnGettingValue(Object, Object, Boolean)

Occurs when the ResourceDictionary receives a request for a resource.

System_CAPS_pubmethodRegisterName(String, Object)

Not supported by this Dictionary implementation.


Removes the entry with the specified key from the base dictionary.


Returns a string that represents the current object.(Inherited from Object.)


Not supported by this Dictionary implementation.

System_CAPS_pubinterfaceSystem_CAPS_privmethodICollection.CopyTo(Array, Int32)

This API supports the product infrastructure and is not intended to be used directly from your code. For a description of this member, see ICollection.CopyTo.


This API supports the product infrastructure and is not intended to be used directly from your code. For a description of this member, see IEnumerable.GetEnumerator.


This API supports the product infrastructure and is not intended to be used directly from your code. For a description of this member, see ICollection.IsSynchronized.


For a description of this member, see ICollection.SyncRoot.


For a description of this member, see IUriContext.BaseUri.


Overloaded. Enables parallelization of a query.(Defined by ParallelEnumerable.)


Overloaded. Converts an IEnumerable to an IQueryable.(Defined by Queryable.)


Casts the elements of an IEnumerable to the specified type.(Defined by Enumerable.)


Filters the elements of an IEnumerable based on a specified type.(Defined by Enumerable.)

The items in a ResourceDictionary are not immediately processed when application code is loaded by a XAML loader. Instead, the ResourceDictionary persists as an object, and the individual values are processed only when they are specifically requested.

The ResourceDictionary class is not derived from DictionaryBase. Instead, the ResourceDictionary class implements IDictionary but relies on a Hashtable internally.

In Extensible Application Markup Language (XAML), the ResourceDictionary class is typically an implicit collection element that is the object element value of several Resources properties, when given in property element syntax. For details on implicit collections in XAML, see XAML Syntax In Detail. An exception is when you want to specify a merged dictionary; for details, see Merged Resource Dictionaries.

Another possible XAML usage is to declare a resource dictionary as a discrete XAML file, and either load it at run time with Load or include it in a (full-trust) project as a resource or loose file. In this case, ResourceDictionary can be declared as an object element, serving as the root element of the XAML. You must map the appropriate XML namespace values (default for the WPF namespace and typically x: for the XAML namespace) onto the ResourceDictionary element if you plan to use it as the root element. Then you can add child elements that define the resources, each with an value.



A property specifying a property element, where the value type of that property is ResourceDictionary. Typically, this is the Resources property of FrameworkElement or FrameworkContentElement, or of Application in an application resources case.


One or more resources specified as object elements. Each resource that you specify must have an x:Key Directive assigned.

.NET Framework
Available since 3.0
Available since 2.0
Windows Phone Silverlight
Available since 7.0

Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
© 2018 Microsoft