    

 ## On this page

  

 

 # Class ObservableKeyedCollection&lt;TKey, TItem\\&gt;

 Last update: 16.07.2025 

Namespace: [VM.Collections](VM.Collections.md)  
Assembly: VM.dll

```csharp
public class ObservableKeyedCollection<TKey, TItem> : ObservableKeyedCollectionBase<TKey, TItem>

```

#### Type Parameters

`TKey`

`TItem`

#### Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) ← [Collection&lt;TItem&gt;](https://learn.microsoft.com/dotnet/api/system.collections.objectmodel.collection-1) ← [KeyedCollection&lt;TKey, TItem&gt;](https://learn.microsoft.com/dotnet/api/system.collections.objectmodel.keyedcollection-2) ← [ObservableKeyedCollectionBase&lt;TKey, TItem&gt;](VM.Collections.ObservableKeyedCollectionBase-2.md) ← [ObservableKeyedCollection&lt;TKey, TItem&gt;](VM.Collections.ObservableKeyedCollection-2.md)

#### Inherited Members

[ObservableKeyedCollectionBase&lt;TKey, TItem&gt;.AddRange(IEnumerable&lt;TItem&gt;)](VM.Collections.ObservableKeyedCollectionBase-2.md#VM_Collections_ObservableKeyedCollectionBase_2_AddRange_System_Collections_Generic_IEnumerable__1__), [ObservableKeyedCollectionBase&lt;TKey, TItem&gt;.TryGetValue(TKey, out TItem)](VM.Collections.ObservableKeyedCollectionBase-2.md#VM_Collections_ObservableKeyedCollectionBase_2_TryGetValue__0__1__), [ObservableKeyedCollectionBase&lt;TKey, TItem&gt;.ClearItems()](VM.Collections.ObservableKeyedCollectionBase-2.md#VM_Collections_ObservableKeyedCollectionBase_2_ClearItems), [ObservableKeyedCollectionBase&lt;TKey, TItem&gt;.InsertItem(int, TItem)](VM.Collections.ObservableKeyedCollectionBase-2.md#VM_Collections_ObservableKeyedCollectionBase_2_InsertItem_System_Int32__1_), [ObservableKeyedCollectionBase&lt;TKey, TItem&gt;.OnCollectionChanged(NotifyCollectionChangedEventArgs)](VM.Collections.ObservableKeyedCollectionBase-2.md#VM_Collections_ObservableKeyedCollectionBase_2_OnCollectionChanged_System_Collections_Specialized_NotifyCollectionChangedEventArgs_), [ObservableKeyedCollectionBase&lt;TKey, TItem&gt;.RemoveItem(int)](VM.Collections.ObservableKeyedCollectionBase-2.md#VM_Collections_ObservableKeyedCollectionBase_2_RemoveItem_System_Int32_), [ObservableKeyedCollectionBase&lt;TKey, TItem&gt;.SetItem(int, TItem)](VM.Collections.ObservableKeyedCollectionBase-2.md#VM_Collections_ObservableKeyedCollectionBase_2_SetItem_System_Int32__1_), [ObservableKeyedCollectionBase&lt;TKey, TItem&gt;.&lt;&gt;OnPropertyChanged(PropertyChangedEventArgs)](VM.Collections.ObservableKeyedCollectionBase-2.md#VM_Collections_ObservableKeyedCollectionBase_2___OnPropertyChanged_System_ComponentModel_PropertyChangedEventArgs_), [ObservableKeyedCollectionBase&lt;TKey, TItem&gt;.CollectionChanged](VM.Collections.ObservableKeyedCollectionBase-2.md#VM_Collections_ObservableKeyedCollectionBase_2_CollectionChanged), [ObservableKeyedCollectionBase&lt;TKey, TItem&gt;.PropertyChanged](VM.Collections.ObservableKeyedCollectionBase-2.md#VM_Collections_ObservableKeyedCollectionBase_2_PropertyChanged)

## Constructors

### ObservableKeyedCollection(Func&lt;TItem, TKey&gt;)

```csharp
public ObservableKeyedCollection(Func<TItem, TKey> getKeyForItem)

```

#### Parameters

`getKeyForItem` [Func](https://learn.microsoft.com/dotnet/api/system.func-2)&lt;TItem, TKey&gt;

## Methods

### GetKeyForItem(TItem)

```csharp
protected override TKey GetKeyForItem(TItem item)

```

#### Parameters

`item` TItem

#### Returns

TKey