ItemCollection.Clear 메서드

정의

컬렉션을 지우고 현재 컬렉션에 있는 모든 항목에 대한 참조를 해제합니다.

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

구현

예외

ItemCollectionItemsSource 모드인 경우. ItemsSource 속성이 설정되면 Items 컬렉션이 읽기 전용이 되고 크기가 고정됩니다.

예제

다음 예제에서는이 메서드를 사용 하는 방법을 보여 있습니다. 예제 sbar 에서 컨트롤은 StatusBar .입니다 ItemsControl.

private void MakeProgressBar(object sender, RoutedEventArgs e)
{
    sbar.Items.Clear();
    TextBlock txtb = new TextBlock();
    txtb.Text = "Progress of download.";
    sbar.Items.Add(txtb);
    ProgressBar progressbar = new ProgressBar();
    progressbar.Width = 100;
    progressbar.Height = 20;
    Duration duration = new Duration(TimeSpan.FromSeconds(5));
    DoubleAnimation doubleanimation =
                               new DoubleAnimation(100.0, duration);
    progressbar.BeginAnimation(ProgressBar.ValueProperty,
                               doubleanimation);
    ToolTip ttprogbar = new ToolTip();
    ttprogbar.Content = "Shows the progress of a download.";
    progressbar.ToolTip = (ttprogbar);
    sbar.Items.Add(progressbar);
}
Private Sub MakeProgressBar(ByVal sender As Object, ByVal e As RoutedEventArgs)
    sbar.Items.Clear()
    Dim txtb As New TextBlock()
    txtb.Text = "Progress of download."
    sbar.Items.Add(txtb)
    Dim progressbar As New ProgressBar()
    progressbar.Width = 100
    progressbar.Height = 20
    Dim duration As New Duration(TimeSpan.FromSeconds(5))
    Dim doubleanimation As New DoubleAnimation(100.0, duration)
    progressbar.BeginAnimation(ProgressBar.ValueProperty, doubleanimation)
    Dim ttprogbar As New ToolTip()
    ttprogbar.Content = "Shows the progress of a download."
    progressbar.ToolTip = (ttprogbar)
    sbar.Items.Add(progressbar)
End Sub

적용 대상

추가 정보