共用方式為


List.ListItems 屬性

定義

取得 ListItemCollection,包含組成 ListItem 內容的 List 項目。

public:
 property System::Windows::Documents::ListItemCollection ^ ListItems { System::Windows::Documents::ListItemCollection ^ get(); };
public System.Windows.Documents.ListItemCollection ListItems { get; }
member this.ListItems : System.Windows.Documents.ListItemCollection
Public ReadOnly Property ListItems As ListItemCollection

屬性值

ListItemCollection,包含組成 ListItem 內容的 List 項目。

此屬性沒有預設值。

範例

下列範例示範如何使用 屬性在 上 ListListItems 執行一般作業。

// Add ListItems to the List.
List listx = new List();
Span spanx = 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.
ListItem lix = new ListItem(new Paragraph(new Run("ListItem to insert...")));
listx.ListItems.InsertBefore(listx.ListItems.FirstListItem, lix);

// Get the number of ListItems in the List.
int countListItems = 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();
' 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()

備註

ListItemCollection使用這個屬性傳回的 來列舉或操作專案的內容 List

適用於