Skip to content

Commit d08e1b7

Browse files
committed
Add new interfaces/members to IReadOnlyObservableGroup
1 parent 2d58242 commit d08e1b7

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

CommunityToolkit.Mvvm/Collections/IReadOnlyObservableGroup.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5+
using System.Collections;
6+
using System.Collections.Specialized;
57
using System.ComponentModel;
68

79
namespace CommunityToolkit.Mvvm.Collections;
810

911
/// <summary>
1012
/// An interface for a grouped collection of items.
1113
/// </summary>
12-
public interface IReadOnlyObservableGroup : INotifyPropertyChanged
14+
public interface IReadOnlyObservableGroup : INotifyPropertyChanged, INotifyCollectionChanged, IEnumerable
1315
{
1416
/// <summary>
1517
/// Gets the key for the current collection.
@@ -20,4 +22,12 @@ public interface IReadOnlyObservableGroup : INotifyPropertyChanged
2022
/// Gets the number of items currently in the grouped collection.
2123
/// </summary>
2224
int Count { get; }
25+
26+
/// <summary>
27+
/// Gets the element at the specified index in the current collection.
28+
/// </summary>
29+
/// <param name="index">The zero-based index of the element to get.</param>
30+
/// <returns>The element at the specified index in the read-only list.</returns>
31+
/// <exception cref="System.ArgumentOutOfRangeException">Thrown if the index is out of range.</exception>
32+
object? this[int index] { get; }
2333
}

CommunityToolkit.Mvvm/Collections/ObservableGroup{TKey,TValue}.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,7 @@ public TKey Key
7171

7272
/// <inheritdoc/>
7373
object IReadOnlyObservableGroup.Key => Key;
74+
75+
/// <inheritdoc/>
76+
object? IReadOnlyObservableGroup.this[int index] => this[index];
7477
}

CommunityToolkit.Mvvm/Collections/ReadOnlyObservableGroup{TKey,TValue}.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,7 @@ public ReadOnlyObservableGroup(ObservableGroup<TKey, TValue> group)
4141

4242
/// <inheritdoc/>
4343
object IReadOnlyObservableGroup.Key => Key;
44+
45+
/// <inheritdoc/>
46+
object? IReadOnlyObservableGroup.this[int index] => this[index];
4447
}

0 commit comments

Comments
 (0)