Export (0) Print
Expand All

ItemCollection.Clear Method

Clears the collection and releases the references on all items currently in the collection.

Namespace:  System.Windows.Controls
Assembly:  PresentationFramework (in PresentationFramework.dll)

Public Sub Clear




The ItemCollection is in ItemsSource mode. (When the ItemsSource property is set, the Items collection will be made read-only and fixed-size.)

The following example shows how to use this method. In the example, sbar is a StatusBar control, which is an ItemsControl.

		Private Sub MakeProgressBar(ByVal sender As Object, ByVal e As RoutedEventArgs)
			Dim txtb As New TextBlock()
			txtb.Text = "Progress of download."
			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)
		End Sub

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

© 2014 Microsoft