ResourceDictionary.Add(Object, Object) 方法

定义

通过键将资源添加到此 ResourceDictionary 中。Adds a resource by key to this ResourceDictionary.

public:
 virtual void Add(System::Object ^ key, System::Object ^ value);
public void Add (object key, object value);
abstract member Add : obj * obj -> unit
override this.Add : obj * obj -> unit
Public Sub Add (key As Object, value As Object)

参数

key
Object

要添加的键的名称。The name of the key to add.

value
Object

要添加的资源的值。The value of the resource to add.

实现

异常

ResourceDictionary 被锁定或为只读。The ResourceDictionary is locked or read-only.

Hashtable 中已存在具有相同键的元素。An element with the same key already exists in the Hashtable.

注解

尝试添加重复的键时引发异常。Attempting to add a duplicate key raises an exception.

密钥始终添加到基本字典。Keys are always added to the base dictionary. 不会检查当前 ResourceDictionaryMergedDictionaries 中的键是否存在重复项,仅检查基本字典中是否有重复项。Keys in MergedDictionaries within the current ResourceDictionary are not checked for duplication, only the base dictionary is checked for duplicates.

适用于