Breyta

Deila með


ResourceDictionary Class

Definition

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

public ref class ResourceDictionary : System::Collections::IDictionary, System::ComponentModel::ISupportInitialize, System::Windows::Markup::INameScope, System::Windows::Markup::IUriContext
[System.Windows.Localizability(System.Windows.LocalizationCategory.Ignore)]
public class ResourceDictionary : System.Collections.IDictionary, System.ComponentModel.ISupportInitialize, System.Windows.Markup.INameScope, System.Windows.Markup.IUriContext
[System.Windows.Localizability(System.Windows.LocalizationCategory.Ignore)]
[System.Windows.Markup.Ambient]
[System.Windows.Markup.UsableDuringInitialization(true)]
public class ResourceDictionary : System.Collections.IDictionary, System.ComponentModel.ISupportInitialize, System.Windows.Markup.INameScope, System.Windows.Markup.IUriContext
[<System.Windows.Localizability(System.Windows.LocalizationCategory.Ignore)>]
type ResourceDictionary = class
    interface IDictionary
    interface ICollection
    interface IEnumerable
    interface INameScope
    interface ISupportInitialize
    interface IUriContext
[<System.Windows.Localizability(System.Windows.LocalizationCategory.Ignore)>]
[<System.Windows.Markup.Ambient>]
[<System.Windows.Markup.UsableDuringInitialization(true)>]
type ResourceDictionary = class
    interface IDictionary
    interface ICollection
    interface IEnumerable
    interface ISupportInitialize
    interface IUriContext
    interface INameScope
[<System.Windows.Localizability(System.Windows.LocalizationCategory.Ignore)>]
[<System.Windows.Markup.Ambient>]
[<System.Windows.Markup.UsableDuringInitialization(true)>]
type ResourceDictionary = class
    interface ICollection
    interface IEnumerable
    interface IDictionary
    interface ISupportInitialize
    interface INameScope
    interface IUriContext
Public Class ResourceDictionary
Implements IDictionary, INameScope, ISupportInitialize, IUriContext
Inheritance
ResourceDictionary
Derived
Attributes
Implements

Remarks

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 x:Key value.

XAML Implicit Collection Usage

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

XAML Values

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.

Constructors

ResourceDictionary()

Initializes a new instance of the ResourceDictionary class.

Properties

Count

Gets the number of entries in the base ResourceDictionary.

DeferrableContent

Gets or sets the deferrable content for this resource dictionary.

InvalidatesImplicitDataTemplateResources

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.

IsFixedSize

Gets whether this ResourceDictionary is fixed-size.

IsReadOnly

Gets whether this ResourceDictionary is read-only.

Item[Object]

Gets or sets the value associated with the given key.

Keys

Gets a collection of all keys contained in this ResourceDictionary.

MergedDictionaries

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

Source

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

Values

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

Methods

Add(Object, Object)

Adds a resource by key to this ResourceDictionary.

BeginInit()

Begins the initialization phase for this ResourceDictionary.

Clear()

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

Contains(Object)

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

CopyTo(DictionaryEntry[], Int32)

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

EndInit()

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

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
FindName(String)

Not supported by this Dictionary implementation.

GetEnumerator()

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

GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
OnGettingValue(Object, Object, Boolean)

Occurs when the ResourceDictionary receives a request for a resource.

RegisterName(String, Object)

Not supported by this Dictionary implementation.

Remove(Object)

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

ToString()

Returns a string that represents the current object.

(Inherited from Object)
UnregisterName(String)

Not supported by this Dictionary implementation.

Explicit Interface Implementations

ICollection.CopyTo(Array, Int32)

For a description of this member, see CopyTo(Array, Int32).

ICollection.IsSynchronized

For a description of this member, see IsSynchronized.

ICollection.SyncRoot

For a description of this member, see SyncRoot.

IEnumerable.GetEnumerator()

For a description of this member, see GetEnumerator().

IUriContext.BaseUri

For a description of this member, see BaseUri.

Extension Methods

Cast<TResult>(IEnumerable)

Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable)

Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable)

Enables parallelization of a query.

AsQueryable(IEnumerable)

Converts an IEnumerable to an IQueryable.

Applies to

See also