UIElementCollection.RemoveAt(Int32) 方法

定義

在指定的索引位置移除 UIElement

public:
 virtual void RemoveAt(int index);
public virtual void RemoveAt (int index);
abstract member RemoveAt : int -> unit
override this.RemoveAt : int -> unit
Public Overridable Sub RemoveAt (index As Integer)

參數

index
Int32

您要移除之 UIElement 的索引。

實作

範例

下列範例會 RemoveAt 使用 方法來移除位於指定索引位置的子內容。

void RemoveButton(object sender, MouseButtonEventArgs e)
{
    if ((sp1.Children.IndexOf(btn) >= 0) || (sp1.Children.IndexOf(btn1) >= 0) || (sp1.Children.IndexOf(btn2) >= 0) || (sp1.Children.IndexOf(btn3) >= 0))
    {
        sp1.Children.RemoveAt(0);
    }
}

適用於