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.
Implements
Inherited Members
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 SourceResourceDictionary()
Constructor for ResourceDictionary
Declaration
public ResourceDictionary()
Properties
| Improve this Doc View SourceCount
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.
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 |
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. |
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 |
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. |
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 |
MergedDictionaries
List of ResourceDictionaries merged into this Resource Dictionary
Declaration
public PresentationFrameworkCollection<ResourceDictionary> MergedDictionaries { get; }
Property Value
| Type | Description |
|---|---|
| PresentationFrameworkCollection<ResourceDictionary> |
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 |
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> |
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 SourceAdd(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. |
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. |
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.
Clear()
Removes all items from this ResourceDictionary.
Declaration
public void Clear()
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. |
ContainsKey(Object)
Declaration
public bool ContainsKey(object key)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | key |
Returns
| Type | Description |
|---|---|
| System.Boolean |
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. |
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. |
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.
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. |
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. |
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 SourceICollection<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 |
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 |
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 |
ICollection<KeyValuePair<Object, Object>>.Count
Declaration
int ICollection<KeyValuePair<object, object>>.Count { get; }
Returns
| Type | Description |
|---|---|
| System.Int32 |
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 |
IDictionary<Object, Object>.Keys
Declaration
ICollection<object> IDictionary<object, object>.Keys { get; }
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.ICollection<System.Object> |
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 |
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 |
IDictionary<Object, Object>.Values
Declaration
ICollection<object> IDictionary<object, object>.Values { get; }
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.ICollection<System.Object> |
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>> |
ICollection.IsSynchronized
Declaration
bool ICollection.IsSynchronized { get; }
Returns
| Type | Description |
|---|---|
| System.Boolean |
ICollection.SyncRoot
Declaration
object ICollection.SyncRoot { get; }
Returns
| Type | Description |
|---|---|
| System.Object |
IEnumerable.GetEnumerator()
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
| Type | Description |
|---|---|
| System.Collections.IEnumerator |