ListItem Class
.NET Framework 3.0
A flow content element that represents a particular content item in an ordered or unordered List.
Namespace: System.Windows.Documents
Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace: http://schemas.microsoft.com/winfx/2006/xaml/presentation
Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace: http://schemas.microsoft.com/winfx/2006/xaml/presentation
'Declaration <ContentPropertyAttribute("Blocks")> _ Public Class ListItem Inherits TextElement 'Usage Dim instance As ListItem
/** @attribute ContentPropertyAttribute("Blocks") */
public class ListItem extends TextElement
ContentPropertyAttribute("Blocks") public class ListItem extends TextElement
<ListItem> Blocks </ListItem>
The following example shows how to define a List using XAML.
<FlowDocument Background="GhostWhite"> <List MarkerOffset="25" MarkerStyle="UpperRoman" StartIndex="5"> <ListItem> <Paragraph>Boron</Paragraph> </ListItem> <ListItem> <Paragraph>Carbon</Paragraph> </ListItem> <ListItem> <Paragraph>Nitrogen</Paragraph> </ListItem> <ListItem> <Paragraph>Oxygen</Paragraph> </ListItem> <ListItem> <Paragraph>Fluorine</Paragraph> </ListItem> <ListItem> <Paragraph>Neon</Paragraph> </ListItem> </List> </FlowDocument>
The following example shows how to create and populate a List programmatically.
List listx = new List(); // Set the space between the markers and list content to 25 DIP. listx.MarkerOffset = 25; // Use uppercase Roman numerals. listx.MarkerStyle = TextMarkerStyle.UpperRoman; // Start list numbering at 5. listx.StartIndex = 5; // Create the list items that will go into the list. ListItem liV = new ListItem(new Paragraph(new Run("Boron"))); ListItem liVI = new ListItem(new Paragraph(new Run("Carbon"))); ListItem liVII = new ListItem(new Paragraph(new Run("Nitrogen"))); ListItem liVIII = new ListItem(new Paragraph(new Run("Oxygen"))); ListItem liIX = new ListItem(new Paragraph(new Run("Fluorine"))); ListItem liX = new ListItem(new Paragraph(new Run("Neon"))); // Finally, add the list items to the list. listx.ListItems.Add(liV); listx.ListItems.Add(liVI); listx.ListItems.Add(liVII); listx.ListItems.Add(liVIII); listx.ListItems.Add(liIX); listx.ListItems.Add(liX);
The following figure shows how this example renders.
The following example shows how to define a nested List (lists within lists) using XAML.
<FlowDocument Background="GhostWhite"> <List MarkerOffset="25" MarkerStyle="UpperRoman" StartIndex="5"> <ListItem> <Paragraph>Boron</Paragraph> <List Margin="0" Padding="0" > <ListItem Margin="40,0,0,0"> <Paragraph>Symbol: B</Paragraph> </ListItem> <ListItem Margin="40,0,0,0"> <Paragraph>Atomic Mass: 10.811</Paragraph> </ListItem> </List> </ListItem> <ListItem> <Paragraph>Carbon</Paragraph> <List Margin="0" Padding="0" > <ListItem Margin="40,0,0,0"> <Paragraph>Symbol: C</Paragraph> </ListItem> <ListItem Margin="40,0,0,0"> <Paragraph>Atomic Mass: 12.0107</Paragraph> </ListItem> </List> </ListItem> <ListItem> <Paragraph>Nitrogen</Paragraph> <List Margin="0" Padding="0" > <ListItem Margin="40,0,0,0"> <Paragraph>Symbol: N</Paragraph> </ListItem> <ListItem Margin="40,0,0,0"> <Paragraph>Atomic Mass: 14.00674</Paragraph> </ListItem> </List> </ListItem> <ListItem> <Paragraph>Oxygen</Paragraph> <List Margin="0" Padding="0" > <ListItem Margin="40,0,0,0"> <Paragraph>Symbol: O</Paragraph> </ListItem> <ListItem Margin="40,0,0,0"> <Paragraph>Atomic Mass: 15.9994</Paragraph> </ListItem> </List> </ListItem> <ListItem> <Paragraph>Fluorine</Paragraph> <List Margin="0" Padding="0" > <ListItem Margin="40,0,0,0"> <Paragraph>Symbol: F</Paragraph> </ListItem> <ListItem Margin="40,0,0,0"> <Paragraph>Atomic Mass: 18.9984032</Paragraph> </ListItem> </List> </ListItem> <ListItem> <Paragraph>Neon</Paragraph> <List Margin="0" Padding="0" > <ListItem Margin="40,0,0,0"> <Paragraph>Symbol: Ne</Paragraph> </ListItem> <ListItem Margin="40,0,0,0"> <Paragraph>Atomic Mass: 20.1797</Paragraph> </ListItem> </List> </ListItem> </List> </FlowDocument>
The following figure shows how this example renders.
Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.Community Additions
ADD
Show: