ResourceDictionary.Add Method (Object, Object)
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Adds an item to the ResourceDictionary.
Assembly: System.Windows (in System.Windows.dll)
Parameters
- key
- Type: System.Object
The string key of the item to add.
- value
- Type: System.Object
The item value to add.
Implements
IDictionary.Add(Object, Object)| Exception | Condition |
|---|---|
| NotSupportedException | Attempted to add Nothing as a value. |
| 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. |
ResourceDictionary supports dictionary APIs that support two signatures for the type of the key component, one that takes strings and one that takes Object. Most Windows Phone scenarios should use strings as the resource key for resources in a ResourceDictionary. The Object as key signatures exist for compatibility and for interface conformance, but internally the dictionary is implemented such that only strings are accepted as keys.