UIElementCollection.Clear Yöntem
Tanım
Tüm öğeleri bir öğesinden kaldırır UIElementCollection .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 ()
Uygulamalar
Örnekler
Aşağıdaki örnek, Clear bir üst öğenin alt içeriğini temizlemek için yöntemini kullanır StackPanel .The following example uses the Clear method to clear child content from a parent StackPanel. Bunu Children , türünde olan özelliğini kullanarak yapabilirsiniz UIElementCollection .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);
}