UIElementCollection.Clear Metoda

Definicja

Usuwa wszystkie elementy z elementu UIElementCollection.

public:
 virtual void Clear();
public virtual void Clear ();
abstract member Clear : unit -> unit
override this.Clear : unit -> unit
Public Overridable Sub Clear ()

Implementuje

Przykłady

W poniższym przykładzie Clear użyto metody w celu wyczyszczenia zawartości podrzędnej z elementu nadrzędnego StackPanel. W tym celu należy użyć Children właściwości , która jest typu UIElementCollection.

void AddButton(object sender, MouseButtonEventArgs e)
{
    sp1.Children.Clear();
    btn = new Button();
    btn.Content = "New Button";
    sp1.Children.Add(btn);
}

Dotyczy

Zobacz też