This includes:
- Create multilevel list template for Heading styles
- Add button in the ribbon list styles gallery for applying this list template
- TOC generated from heading styles associated with list should also include the numbering of the headings (see the related bug 91763). This is not absolutely required for the current item.
--------------------
Currently such list can be added using the following code:
private void button1_Click(object sender, RoutedEventArgs e)
{
ListStyle listStyle = CreateHierarchicalListStyle();
for (int i = 0; i < 9; i++)
{
ListLevelStyle listLevel = listStyle.Levels[i];
listLevel.HangingIndent = 0;
listLevel.Indent = 0;
listLevel.StyleName = RadDocumentDefaultStyles.GetHeadingStyleNameByIndex(i + 1);
}
DocumentList documentList = new DocumentList(listStyle, this.radRichTextBox.Document);
for (int i = 0; i < 9; i++)
{
string headingStyleName = RadDocumentDefaultStyles.GetHeadingStyleNameByIndex(i + 1);
StyleDefinition headingStyle = this.radRichTextBox.Document.StyleRepository.GetValueOrNull(headingStyleName);
headingStyle.ParagraphStyle.ListId = documentList.ID;
headingStyle.ParagraphStyle.ListLevel = i;
}
}
private static ListStyle CreateHierarchicalListStyle()
{
ListStyle listStyle = new ListStyle();
for (int i = 0; i < ListStyle.ListLevels; ++i)
{
StringBuilder levelText = new StringBuilder();
for (int j = 0; j < i + 1; ++j)
{
levelText.Append("{" + j + "}.");
}
listStyle.Levels.Add(new ListLevelStyle()
{
StartingIndex = 1,
NumberingFormat = ListNumberingFormat.Decimal,
LevelText = levelText.ToString(),
});
}
return listStyle;
}