In This Article

KeyedObservableCollection<T> Class

Provides a generic keyed collection that provides notifications when items are added or removed.

public class KeyedObservableCollection<T> : SimpleObservableCollection<T>, IKeyedObservableCollection<T>, IObservableCollection<T> where T : class, IKeyedObject
Type Parameters:
T -
Inheritance:
object Collection<T> SimpleObservableCollection<T> object
Derived:
LexicalStateCollection KeyedSynchronizedCollection<T> EditorViewMarginCollection PrinterViewMarginCollection
Implements:
IKeyedObservableCollection<T> IObservableCollection<T>

Constructors

KeyedObservableCollection()

Initializes an instance of the class.

public KeyedObservableCollection()

Properties

this[string]

Gets the T with the specified key.

[C#] In C#, this property is the indexer for the IKeyedObservableCollection interface.

public virtual T this[string key] { get; }
Parameter Type Description
key string

The key of the T to return.

Property Value

T:

The T with the specified key.

Methods

Contains(string)

Determines whether a T with the specified key is in the collection.

public bool Contains(string key)
Parameter Type Description
key string

The key to locate in the collection.

Returns

bool:

true if a T with the specified key is found in the collection; otherwise, false.

IndexOf(string)

Searches for a T with the specified key and returns the zero-based index of the first occurrence within the entire collection.

public virtual int IndexOf(string key)
Parameter Type Description
key string

The key to locate in the collection.

Returns

int:

The zero-based index of the first occurrence of a T with the specified key within the entire collection, if found; otherwise, -1.

Remove(string)

Removes the T with the specified key.

public virtual bool Remove(string key)
Parameter Type Description
key string

The key to locate in the collection.

Returns

bool:

true if a T was removed; otherwise, false.

Inherited Members