UIElementCollection.Clear 메서드

정의

UIElementCollection에서 요소를 모두 제거합니다.

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

구현

예제

다음 예제에서는 합니다 Clear 메서드는 부모에서 자식 콘텐츠를 지우려면 StackPanel합니다. 사용 하 여이 작업을 수행 합니다 Children 형식인 속성 UIElementCollection합니다.

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

적용 대상

추가 정보