Udostępnij za pośrednictwem


ItemCollection Class

Definition

Holds the list of items that represent the content of an ItemsControl.

public ref class ItemCollection sealed : IIterable<Platform::Object ^>, IObservableVector<Platform::Object ^>, IVector<Platform::Object ^>
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class ItemCollection final : IIterable<IInspectable>, IObservableVector<IInspectable>, IVector<IInspectable>
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class ItemCollection final : IIterable<IInspectable>, IObservableVector<IInspectable>, IVector<IInspectable>
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class ItemCollection : IEnumerable<object>, IList<object>, IObservableVector<object>
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class ItemCollection : IEnumerable<object>, IList<object>, IObservableVector<object>
Public NotInheritable Class ItemCollection
Implements IEnumerable(Of Object), IList(Of Object), IObservableVector(Of Object)
<ItemsControl>
  oneOrMoreFrameworkElements
</ItemsControl>
Inheritance
Object Platform::Object IInspectable ItemCollection
Attributes
Implements
IEnumerable<Object> IIterable<Platform::Object> IIterable<IInspectable> IIterable<T> IEnumerable<T> IList<Object> IVector<Platform::Object> IVector<IInspectable> IVector<T> IList<T> IObservableVector<Object> IObservableVector<Platform::Object> IObservableVector<IInspectable>

Windows requirements

Device family
Windows 10 (introduced in 10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v1.0)

Remarks

Enumerating the collection in C# or Microsoft Visual Basic

An ItemCollection is enumerable, so you can use language-specific syntax such as foreach in C# to enumerate the items in the collection. The compiler does the type-casting for you and you won't need to cast to IEnumerable explicitly. If you do need to cast explicitly, for example if you want to call GetEnumerator, cast to IEnumerable<T>with an Object or FrameworkElement constraint.

Properties

Size

Gets the size (count) of the collection.

Methods

Append(Object)

Adds a new item to the collection.

Clear()

Removes all items from the collection.

First()

Returns the iterator for iteration over the items in the collection.

GetAt(UInt32)

Returns the item located at the specified index.

GetMany(UInt32, Object[])

Retrieves multiple elements in a single pass through the iterator.

GetView()

Gets an immutable view into the collection.

IndexOf(Object, UInt32)

Retrieves the index of the specified item.

InsertAt(UInt32, Object)

Inserts the specified item at the specified index.

RemoveAt(UInt32)

Removes the item at the specified index.

RemoveAtEnd()

Removes the last item in the collection.

ReplaceAll(Object[])

Initially clears the collection, then inserts the provided array as new items.

SetAt(UInt32, Object)

Sets the value at the specified index to the item value specified.

Events

VectorChanged

Occurs when the items list of the collection has changed, or the collection is reset.

Applies to

See also