Reputation: 11
How can i do this with code?
<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>
</List>
</FlowDocument>
specifically:
<Paragraph>Boron</Paragraph>
<List Margin="0" Padding="0" >
this part.
Upvotes: 0
Views: 1458
Reputation: 69979
From the MSDN page @Clemens added a link to, List class:
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);
Notice where the ListItem
s are created. Each ListItem
is constructed with a new Paragraph
object, which is constructed with a new Run
object, which is in turn constructed with a text string. This is how you add text to a Paragraph
in code. In XAML, the Run
object is implicitly added by the WPF Framework although you also can declare them explicitly.
<Paragraph>
<Run>Boron</Run>
</Paragraph>
Upvotes: 1