次の方法で共有


ResourceDictionary.Item Property

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Gets the element at the specified index.

Namespace:  System.Windows
Assembly:  System.Windows (in System.Windows.dll)

Syntax

'Declaration
Public Property Item ( _
    key As Object _
) As Object
public Object this[
    Object key
] { get; set; }

Parameters

Property Value

Type: System.Object
The object if it exists; otherwise, nulla null reference (Nothing in Visual Basic).

Implements

IDictionary.Item[Object]

Exceptions

Exception Condition
NotImplementedException

Attempted to set a value using the indexer.

ArgumentNullException

key is nulla null reference (Nothing in Visual Basic).

ArgumentException

key is not a string.

Remarks

The main scenario for using the ResourceDictionary is to retrieve resources from a specific Silverlight ResourceDictionary at run time. For more information, see Referencing Resources from Code.

This indexer implementation specifically blocks a "set" usage. If you attempt to set a value using the indexer, an exception is thrown. You must remove and re-add to the ResourceDictionary in order to change a key-value pair.

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.