List.IsListStyleReference property

Returns true if this list is a reference to a list style.

public bool IsListStyleReference { get; }


Note, modifying properties of a list that is a reference to list style has no effect. The list formatting specified in the list style itself always takes precedence.


Shows how to create a list style and use it in a document.

Document doc = new Document();

// A list allows us to organize and decorate sets of paragraphs with prefix symbols and indents.
// We can create nested lists by increasing the indent level. 
// We can begin and end a list by using a document builder's "ListFormat" property. 
// Each paragraph that we add between a list's start and the end will become an item in the list.
// We can contain an entire List object within a style.
Style listStyle = doc.Styles.Add(StyleType.List, "MyListStyle");

List list1 = listStyle.List;

Assert.AreEqual(listStyle, list1.Style);

// Change the appearance of all list levels in our list.
foreach (ListLevel level in list1.ListLevels)
    level.Font.Name = "Verdana";
    level.Font.Color = Color.Blue;
    level.Font.Bold = true;

DocumentBuilder builder = new DocumentBuilder(doc);

builder.Writeln("Using list style first time:");

// Create another list from a list within a style.
List list2 = doc.Lists.Add(listStyle);

Assert.AreEqual(listStyle, list2.Style);

// Add some list items that our list will format.
builder.ListFormat.List = list2;
builder.Writeln("Item 1");
builder.Writeln("Item 2");

builder.Writeln("Using list style second time:");

// Create and apply another list based on the list style.
List list3 = doc.Lists.Add(listStyle);
builder.ListFormat.List = list3;
builder.Writeln("Item 1");
builder.Writeln("Item 2");

builder.Document.Save(ArtifactsDir + "Lists.CreateAndUseListStyle.docx");

See Also