UIElementCollection クラス

定義

UIElement オブジェクトの順序付けられたコレクションを表します。

public ref class UIElementCollection sealed : IIterable<UIElement ^>, IVector<UIElement ^>
/// [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 UIElementCollection final : IIterable<UIElement>, IVector<UIElement>
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class UIElementCollection final : IIterable<UIElement>, IVector<UIElement>
[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 UIElementCollection : IEnumerable<UIElement>, IList<UIElement>
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class UIElementCollection : IEnumerable<UIElement>, IList<UIElement>
Public NotInheritable Class UIElementCollection
Implements IEnumerable(Of UIElement), IList(Of UIElement)
<panelobject>
  oneOrMoreChildren
</panelobject>
継承
Object Platform::Object IInspectable UIElementCollection
属性
実装

Windows の要件

デバイス ファミリ
Windows 10 (10.0.10240.0 で導入)
API contract
Windows.Foundation.UniversalApiContract (v1.0 で導入)

注釈

UIElementCollection は、PanelChildren プロパティから取得するオブジェクトの種類です。 たとえば、Grid.Children から値を取得した場合、その値は UIElementCollection インスタンスです。 Windows ランタイム API で UIElementCollection を使用するすべてのプロパティは読み取り専用プロパティです。このプロパティは、オブジェクトが最初にインスタンス化されるときに 0 個の項目で初期化されます。 ただし、UIElementCollection プロパティとメソッドを使用して、実行時にコレクション内の項目を追加、削除、またはクエリできます。

UIElementCollection 内の項目の型は、 UIElement として制約されます。 ただし、UIElement は XAML を使用するWindows ランタイムの基本要素クラスであるため、UIElement として扱うことができる数百の要素型があり、UIElementCollection 内の項目の 1 つになる可能性があります。

C# または Microsoft Visual Basic でのコレクションの列挙

UIElementCollection は列挙可能であるため、C# の foreach などの言語固有の構文を使用して、UIElementCollection 内の項目を列挙できます。 コンパイラは型キャストを行います。明示的に キャストする IEnumerable<UIElement> 必要はありません。 GetEnumerator を呼び出す場合など、明示的にキャストする必要がある場合は、UIElement 制約を使用して IEnumerable<T> にキャストします。

プロパティ

Size

コレクションのサイズ (カウント) を取得します。

メソッド

Append(UIElement)

新しい項目をコレクションに追加します。

Clear()

コレクションからすべての項目を削除します。

First()

UIElementCollection 内の項目を反復処理できる反復子オブジェクトを返します。

GetAt(UInt32)

指定したインデックスにある項目を返します。

GetMany(UInt32, UIElement[])

反復子を通過する 1 つのパス内の複数の要素を取得します。

GetView()

コレクションに変更できないビューを取得します。

IndexOf(UIElement, UInt32)

指定した項目のインデックスを取得します。

InsertAt(UInt32, UIElement)

指定したインデックス位置に指定した項目を挿入します。

Move(UInt32, UInt32)

指定されたインデックス位置にある項目をコレクション内の別の位置に移動します。

RemoveAt(UInt32)

指定したインデックス位置にある項目を削除します。

RemoveAtEnd()

コレクション内の最後の項目を削除します。

ReplaceAll(UIElement[])

最初にコレクションをクリアし、指定された配列を新しい項目として挿入します。

SetAt(UInt32, UIElement)

指定したインデックスの値を、指定した UIElement 値に設定します。

適用対象

こちらもご覧ください