StyleName
Contents
[
Hide
]StructuredDocumentTag.StyleName property
Gets or sets the name of the style applied to the structured document tag.
public string StyleName { get; set; }
Examples
Shows how to work with styles for content control elements.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Below are two ways to apply a style from the document to a structured document tag.
// 1 - Apply a style object from the document's style collection:
Style quoteStyle = doc.Styles[StyleIdentifier.Quote];
StructuredDocumentTag sdtPlainText =
new StructuredDocumentTag(doc, SdtType.PlainText, MarkupLevel.Inline) { Style = quoteStyle };
// 2 - Reference a style in the document by name:
StructuredDocumentTag sdtRichText =
new StructuredDocumentTag(doc, SdtType.RichText, MarkupLevel.Inline) { StyleName = "Quote" };
builder.InsertNode(sdtPlainText);
builder.InsertNode(sdtRichText);
Assert.AreEqual(NodeType.StructuredDocumentTag, sdtPlainText.NodeType);
NodeCollection tags = doc.GetChildNodes(NodeType.StructuredDocumentTag, true);
foreach (Node node in tags)
{
StructuredDocumentTag sdt = (StructuredDocumentTag)node;
Console.WriteLine(sdt.WordOpenXMLMinimal);
Assert.AreEqual(StyleIdentifier.Quote, sdt.Style.StyleIdentifier);
Assert.AreEqual("Quote", sdt.StyleName);
}
See Also
- class StructuredDocumentTag
- namespace Aspose.Words.Markup
- assembly Aspose.Words