Show / Hide Table of Contents

Class ResourceDictionary

Defines a dictionary that contains resources used by components of the app. This dictionary is oriented toward defining the resources in XAML, and then retrieving them through XAML references via the StaticResource markup extension. Alternatively you can access resources by traversing the dictionary at run time.

Inheritance
System.Object
DependencyObject
ResourceDictionary
Implements
System.Collections.Generic.IDictionary<System.Object, System.Object>
System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<System.Object, System.Object>>
System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<System.Object, System.Object>>
System.Collections.IDictionary
System.Collections.ICollection
System.Collections.IEnumerable
System.ComponentModel.ISupportInitialize
INameScope
Inherited Members
DependencyObject.GetValue(DependencyProperty)
DependencyObject.SetCurrentValue(DependencyProperty, Object)
DependencyObject.ReadLocalValue(DependencyProperty)
DependencyObject.SetValue(DependencyProperty, Object)
DependencyObject.SetValue(DependencyPropertyKey, Object)
DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs)
DependencyObject.CoerceValue(DependencyProperty)
DependencyObject.Dispatcher
DependencyObject.INTERNAL_OnAttachedToVisualTree()
DependencyObject.INTERNAL_OnDetachedFromVisualTree()
DependencyObject.ClearValue(DependencyProperty)
DependencyObject.ClearValue(DependencyPropertyKey)
DependencyObject.CheckAccess()
DependencyObject.GetAnimationBaseValue(DependencyProperty)
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: System.Windows
Assembly: OpenSilver.dll
Syntax
public class ResourceDictionary : DependencyObject, IDependencyObject, IDictionary<object, object>, ICollection<KeyValuePair<object, object>>, IEnumerable<KeyValuePair<object, object>>, IDictionary, ICollection, IEnumerable, ISupportInitialize, INameScope

Constructors

| Improve this Doc View Source

ResourceDictionary()

Constructor for ResourceDictionary

Declaration
public ResourceDictionary()

Properties

| Improve this Doc View Source

Count

Gets the number of elements contained in the collection.

Declaration
public int Count { get; }
Property Value
Type Description
System.Int32

The number of elements contained in the collection.

Remarks

Elements stored in the MergedDictionaries property are not counted.

| Improve this Doc View Source

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.

Declaration
public bool InvalidatesImplicitDataTemplateResources { get; set; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

IsFixedSize

Gets a value indicating whether the ResourceDictionary has a fixed size.

Declaration
public bool IsFixedSize { get; }
Property Value
Type Description
System.Boolean

Always returns false.

| Improve this Doc View Source

IsReadOnly

Gets a value indicating whether the collection is read-only.

Declaration
public bool IsReadOnly { get; }
Property Value
Type Description
System.Boolean

Always returns false

| Improve this Doc View Source

Item[Object]

Gets or sets the value associated with the specified key.

Declaration
public object this[object key] { get; set; }
Parameters
Type Name Description
System.Object key
Property Value
Type Description
System.Object
Remarks

Fire Invalidations only for changes made after the Init Phase If the key is not found on this ResourceDictionary, it will look on any MergedDictionaries for it

Exceptions
Type Condition
System.ArgumentNullException

key is null.

| Improve this Doc View Source

Keys

Gets an System.Collections.ICollection object containing the keys of the ResourceDictionary.

Declaration
public ICollection Keys { get; }
Property Value
Type Description
System.Collections.ICollection
| Improve this Doc View Source

MergedDictionaries

List of ResourceDictionaries merged into this Resource Dictionary

Declaration
public PresentationFrameworkCollection<ResourceDictionary> MergedDictionaries { get; }
Property Value
Type Description
PresentationFrameworkCollection<ResourceDictionary>
| Improve this Doc View Source

Source

Gets or sets a Uniform Resource Identifier (URI) that provides the source location of a merged resource dictionary.

Declaration
public Uri Source { get; set; }
Property Value
Type Description
System.Uri
| Improve this Doc View Source

ThemeDictionaries

Gets a collection of merged resource dictionaries that are specifically keyed and composed to address theme scenarios

Declaration
public IDictionary<object, ResourceDictionary> ThemeDictionaries { get; }
Property Value
Type Description
System.Collections.Generic.IDictionary<System.Object, ResourceDictionary>
| Improve this Doc View Source

Values

Gets an System.Collections.ICollection object containing the values of the ResourceDictionary.

Declaration
public ICollection Values { get; }
Property Value
Type Description
System.Collections.ICollection

Methods

| Improve this Doc View Source

Add(Object, Object)

Adds an item to the ResourceDictionary.

Declaration
public void Add(object key, object value)
Parameters
Type Name Description
System.Object key

The string key of the item to add.

System.Object value

The item value to add.

Exceptions
Type Condition
System.NotSupportedException

Attempted to add null as a value.

System.ArgumentException

Attempted to add an item with a key that already exists in this ResourceDictionary.-or-Attempted to use a key that is not a string.

| Improve this Doc View Source

Add(String, Object)

Adds an item to the ResourceDictionary.

Declaration
public void Add(string key, object value)
Parameters
Type Name Description
System.String key

The string key of the item to add.

System.Object value

The item value to add.

Exceptions
Type Condition
System.NotSupportedException

Attempted to add null as a value.

System.ArgumentException

Attempted to add an item with a key that already exists in this ResourceDictionary.

| Improve this Doc View Source

BeginInit()

Mark the begining of the Init phase

Declaration
public void BeginInit()
Remarks

BeginInit and EndInit follow a transaction model. BeginInit marks the dictionary uninitialized and EndInit marks it initialized.

| Improve this Doc View Source

Clear()

Removes all items from this ResourceDictionary.

Declaration
public void Clear()
| Improve this Doc View Source

Contains(Object)

Returns a value that indicates whether a specified key exists in the ResourceDictionary.

Declaration
public bool Contains(object key)
Parameters
Type Name Description
System.Object key

The key to check for in the ResourceDictionary.

Returns
Type Description
System.Boolean

true if an item with that key exists in the ResourceDictionary; otherwise, false.

Exceptions
Type Condition
System.ArgumentNullException

key is null.

| Improve this Doc View Source

ContainsKey(Object)

Contains(Object)

Declaration
public bool ContainsKey(object key)
Parameters
Type Name Description
System.Object key
Returns
Type Description
System.Boolean
| Improve this Doc View Source

CopyTo(Array, Int32)

Copies the elements of the ResourceDictionary to an System.Array, starting at a particular System.Array index.

Declaration
public void CopyTo(Array array, int index)
Parameters
Type Name Description
System.Array array

The one-dimensional System.Array that is the destination of the elements copied from ResourceDictionary. The System.Array must have zero-based indexing.

System.Int32 index

The zero-based index in array at which copying begins.

| Improve this Doc View Source

CopyTo(DictionaryEntry[], Int32)

Copies the dictionary's elements to a one-dimensional Array instance at the specified index.

Declaration
public void CopyTo(DictionaryEntry[] array, int arrayIndex)
Parameters
Type Name Description
System.Collections.DictionaryEntry[] array

The one-dimensional Array that is the destination of the DictionaryEntry objects copied from Dictionary. The Array must have zero-based indexing.

System.Int32 arrayIndex

The zero-based index in array at which copying begins.

| Improve this Doc View Source

EndInit()

Fire Invalidation at the end of Init phase

Declaration
public void EndInit()
Remarks

BeginInit and EndInit follow a transaction model. BeginInit marks the dictionary uninitialized and EndInit marks it initialized.

| Improve this Doc View Source

GetEnumerator()

Exposes the enumerator, which supports a simple iteration over a non-generic collection.

Declaration
public IDictionaryEnumerator GetEnumerator()
Returns
Type Description
System.Collections.IDictionaryEnumerator

An enumerator that can be used to iterate through the collection.

| Improve this Doc View Source

Remove(Object)

Removes a specific item from the ResourceDictionary.

Declaration
public void Remove(object key)
Parameters
Type Name Description
System.Object key

The key of the item to remove.

Exceptions
Type Condition
System.ArgumentNullException

key is null.

| Improve this Doc View Source

Remove(String)

Removes a specific item from the ResourceDictionary.

Declaration
public void Remove(string key)
Parameters
Type Name Description
System.String key

The string key of the item to remove.

Exceptions
Type Condition
System.ArgumentNullException

key is null.

Explicit Interface Implementations

| Improve this Doc View Source

ICollection<KeyValuePair<Object, Object>>.Add(KeyValuePair<Object, Object>)

Declaration
void ICollection<KeyValuePair<object, object>>.Add(KeyValuePair<object, object> item)
Parameters
Type Name Description
System.Collections.Generic.KeyValuePair<System.Object, System.Object> item
| Improve this Doc View Source

ICollection<KeyValuePair<Object, Object>>.Contains(KeyValuePair<Object, Object>)

Declaration
bool ICollection<KeyValuePair<object, object>>.Contains(KeyValuePair<object, object> item)
Parameters
Type Name Description
System.Collections.Generic.KeyValuePair<System.Object, System.Object> item
Returns
Type Description
System.Boolean
| Improve this Doc View Source

ICollection<KeyValuePair<Object, Object>>.CopyTo(KeyValuePair<Object, Object>[], Int32)

Declaration
void ICollection<KeyValuePair<object, object>>.CopyTo(KeyValuePair<object, object>[] array, int arrayIndex)
Parameters
Type Name Description
System.Collections.Generic.KeyValuePair<System.Object, System.Object>[] array
System.Int32 arrayIndex
| Improve this Doc View Source

ICollection<KeyValuePair<Object, Object>>.Count

Declaration
int ICollection<KeyValuePair<object, object>>.Count { get; }
Returns
Type Description
System.Int32
| Improve this Doc View Source

ICollection<KeyValuePair<Object, Object>>.Remove(KeyValuePair<Object, Object>)

Declaration
bool ICollection<KeyValuePair<object, object>>.Remove(KeyValuePair<object, object> item)
Parameters
Type Name Description
System.Collections.Generic.KeyValuePair<System.Object, System.Object> item
Returns
Type Description
System.Boolean
| Improve this Doc View Source

IDictionary<Object, Object>.Keys

Declaration
ICollection<object> IDictionary<object, object>.Keys { get; }
Returns
Type Description
System.Collections.Generic.ICollection<System.Object>
| Improve this Doc View Source

IDictionary<Object, Object>.Remove(Object)

Declaration
bool IDictionary<object, object>.Remove(object key)
Parameters
Type Name Description
System.Object key
Returns
Type Description
System.Boolean
| Improve this Doc View Source

IDictionary<Object, Object>.TryGetValue(Object, out Object)

Declaration
bool IDictionary<object, object>.TryGetValue(object key, out object value)
Parameters
Type Name Description
System.Object key
System.Object value
Returns
Type Description
System.Boolean
| Improve this Doc View Source

IDictionary<Object, Object>.Values

Declaration
ICollection<object> IDictionary<object, object>.Values { get; }
Returns
Type Description
System.Collections.Generic.ICollection<System.Object>
| Improve this Doc View Source

IEnumerable<KeyValuePair<Object, Object>>.GetEnumerator()

Declaration
IEnumerator<KeyValuePair<object, object>> IEnumerable<KeyValuePair<object, object>>.GetEnumerator()
Returns
Type Description
System.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<System.Object, System.Object>>
| Improve this Doc View Source

ICollection.IsSynchronized

Declaration
bool ICollection.IsSynchronized { get; }
Returns
Type Description
System.Boolean
| Improve this Doc View Source

ICollection.SyncRoot

Declaration
object ICollection.SyncRoot { get; }
Returns
Type Description
System.Object
| Improve this Doc View Source

IEnumerable.GetEnumerator()

Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type Description
System.Collections.IEnumerator

Implements

System.Collections.Generic.IDictionary<TKey, TValue>
System.Collections.Generic.ICollection<T>
System.Collections.Generic.IEnumerable<T>
System.Collections.IDictionary
System.Collections.ICollection
System.Collections.IEnumerable
System.ComponentModel.ISupportInitialize
INameScope

Extension Methods

DependencyObjectHelper.GetSelfAndAncestors(DependencyObject)
ResourceDictionaryExtensions.ShallowCopy(ResourceDictionary)
VisualTreeExtensions.GetVisualAncestors(DependencyObject)
VisualTreeExtensions.GetVisualAncestorsAndSelf(DependencyObject)
VisualTreeExtensions.GetVisualChildren(DependencyObject)
VisualTreeExtensions.GetVisualChildrenAndSelf(DependencyObject)
VisualTreeExtensions.GetVisualDescendants(DependencyObject)
VisualTreeExtensions.GetVisualDescendantsAndSelf(DependencyObject)
VisualTreeExtensions.GetVisualSiblings(DependencyObject)
VisualTreeExtensions.GetVisualSiblingsAndSelf(DependencyObject)
  • Improve this Doc
  • View Source