ResourceDictionary Class

 

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)


[LocalizabilityAttribute(LocalizationCategory.Ignore)]
[AmbientAttribute]
[UsableDuringInitializationAttribute(true)]
public class ResourceDictionary : IDictionary, ICollection, IEnumerable, 
	ISupportInitialize, IUriContext, INameScope

NameDescription
System_CAPS_pubmethodResourceDictionary()

Initializes a new instance of the ResourceDictionary class.

NameDescription
System_CAPS_pubpropertyCount

Gets the number of entries in the base ResourceDictionary.

System_CAPS_pubpropertyDeferrableContent

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.

System_CAPS_pubpropertyIsFixedSize

Gets whether this ResourceDictionary is fixed-size.

System_CAPS_pubpropertyIsReadOnly

Gets whether this ResourceDictionary is read-only.

System_CAPS_pubpropertyItem[Object]

Gets or sets the value associated with the given key.

System_CAPS_pubpropertyKeys

Gets a collection of all keys contained in this ResourceDictionary.

System_CAPS_pubpropertyMergedDictionaries

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

System_CAPS_pubpropertySource

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

System_CAPS_pubpropertyValues

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

NameDescription
System_CAPS_pubmethodAdd(Object, Object)

Adds a resource by key to this ResourceDictionary.

System_CAPS_pubmethodBeginInit()

Begins the initialization phase for this ResourceDictionary.

System_CAPS_pubmethodClear()

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

System_CAPS_pubmethodContains(Object)

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.

System_CAPS_pubmethodEndInit()

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

System_CAPS_pubmethodEquals(Object)

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

System_CAPS_protmethodFinalize()

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

System_CAPS_pubmethodFindName(String)

Not supported by this Dictionary implementation.

System_CAPS_pubmethodGetEnumerator()

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

System_CAPS_pubmethodGetHashCode()

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

System_CAPS_pubmethodGetType()

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

System_CAPS_protmethodMemberwiseClone()

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.

System_CAPS_pubmethodRemove(Object)

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

System_CAPS_pubmethodToString()

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

System_CAPS_pubmethodUnregisterName(String)

Not supported by this Dictionary implementation.

NameDescription
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.

System_CAPS_pubinterfaceSystem_CAPS_privmethodIEnumerable.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 IEnumerable.GetEnumerator.

System_CAPS_pubinterfaceSystem_CAPS_privpropertyICollection.IsSynchronized

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.

System_CAPS_pubinterfaceSystem_CAPS_privpropertyICollection.SyncRoot

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

System_CAPS_pubinterfaceSystem_CAPS_privpropertyIUriContext.BaseUri

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

NameDescription
System_CAPS_pubmethodAsParallel()

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

System_CAPS_pubmethodAsQueryable()

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

System_CAPS_pubmethodCast<TResult>()

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

System_CAPS_pubmethodOfType<TResult>()

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.

<object>
  <object.resourcesProperty>
    oneOrMoreResources
  </object.resourcesProperty>
</object>

resourcesProperty

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.

oneOrMoreResources

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
Silverlight
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
Show: