ItemCollection.Clear Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Clears the collection and releases the references on all items currently in the collection.
public:
virtual void Clear();
public void Clear ();
abstract member Clear : unit -> unit
override this.Clear : unit -> unit
Public Sub Clear ()
Implements
Exceptions
The ItemCollection is in ItemsSource mode. (When the ItemsSource property is set, the Items collection will be made read-only and fixed-size.)
Examples
The following example shows how to use this method. In the example, sbar
is a StatusBar control, which is an 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
Applies to
See also
GitHub에서 Microsoft와 공동 작업
이 콘텐츠의 원본은 GitHub에서 찾을 수 있으며, 여기서 문제와 끌어오기 요청을 만들고 검토할 수도 있습니다. 자세한 내용은 참여자 가이드를 참조하세요.
.NET