Uredi

Deli z drugimi prek


UIElementCollection.Clear Method

Definition

Removes all elements from a UIElementCollection.

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

Implements

Examples

The following example uses the Clear method to clear child content from a parent StackPanel. You do this by using the Children property, which is of type UIElementCollection.

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

Applies to

See also