UIElementCollection.Item[Int32] 屬性

定義

取得或設定 UIElement,這個項目儲存在 UIElementCollection 之以零起始的索引位置。

public:
 virtual property System::Windows::UIElement ^ default[int] { System::Windows::UIElement ^ get(int index); void set(int index, System::Windows::UIElement ^ value); };
public virtual System.Windows.UIElement this[int index] { get; set; }
member this.Item(int) : System.Windows.UIElement with get, set
Default Public Overridable Property Item(index As Integer) As UIElement

參數

index
Int32

UIElement 的索引位置。

屬性值

指定 index 位置上的 UIElement

範例

下列範例會 Item[] 使用 屬性來識別位於指定索引位置的子專案。

void GetItem(object sender, RoutedEventArgs e)
{
    TextBlock txt2 = new TextBlock();
    sp1.Children.Add(txt2);
    txt2.Text = "UIElement at Index position [0] is " + sp1.Children[0].ToString();
}

適用於