Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

UIElementCollection.RemoveAt Method

Removes the UIElement at the specified index.

Namespace: System.Windows.Controls
Assembly: PresentationFramework (in presentationframework.dll)

public virtual void RemoveAt (
	int index
)
public void RemoveAt (
	int index
)
public function RemoveAt (
	index : int
)
You cannot use methods in XAML.

Parameters

index

The index of the UIElement that you want to remove.

The following example uses the RemoveAt method to remove child content at a specified index position. For the complete sample, see Using Elements Sample.

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);
    }
}

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions

Show:
© 2014 Microsoft