List.ListItems Property

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Gets a ListItemCollection containing the ListItem elements that comprise the contents of the List.

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

Public ReadOnly Property ListItems As ListItemCollection

Property Value

Type: System.Windows.Documents.ListItemCollection

A ListItemCollection containing the ListItem elements that comprise the contents of the List.

This property has no default value.

Use the ListItemCollection returned by this property to enumerate or manipulate the contents of a List element.

The following examples show how to perform common operations on a List using the ListItems property.

' Add ListItems to the List.
Dim listx As New List()
Dim spanx As New Span()
listx.ListItems.Add(New ListItem(New Paragraph(New Run("A bit of text content..."))))
listx.ListItems.Add(New ListItem(New Paragraph(New Run("A bit more text content..."))))

' Insert a ListItem at the begining of the List.
Dim lix As New ListItem(New Paragraph(New Run("ListItem to insert...")))
listx.ListItems.InsertBefore(listx.ListItems.FirstListItem, lix)

' Get the number of ListItems in the List.
Dim countListItems As Integer = listx.ListItems.Count

' Remove the last ListItem from the List.
listx.ListItems.Remove(listx.ListItems.LastListItem)

' Clear all of the ListItems from the List.
listx.ListItems.Clear()

.NET Framework
Available since 3.0
Return to top
Show: