Text Formatting Using SpanAdv in WPF RichTextBoxAdv (Classic)

5 May 20212 minutes to read

As Inline will be the content property of ParagraphAdv, SpanAdv can be added only inside the ParagraphAdv. Every ParagraphAdv can keep n number of inline elements inside it. It allows you to display the formatted text using advanced features like font size, font family, strikethrough, and baseline.

Properties

Property Description Type Data Type
Text Contains the text information. Dependency Property String
Baseline Indicates whether the inline’s text is subscript or superscript. Dependency Property Baseline
FontFamily Specifies the font family of the text. Dependency Property FontFamily
FontSize Specifies the size of the font. Dependency Property. Double
Foreground Designates the font color. Dependency Property Color
HighlightColor Designates the highlight color of the text. Dependency Property Color
Strikethrough Shows whether the text has SingleStrikeThrough or DoubleStrikeThrough. Dependency Property StrikeThrough
FontWeight Indicates the font weight of the text. Dependency Property FontWeight
Underline Indicates whether the text should be underlined. Dependency Property Underline

Adding SpanAdv to an Application

SpanAdv can be added directly to an application using the following code snippet:

<syncfusion:RichTextBoxAdv Height="300" Width="400" x:Name="richtext">            
<syncfusion:DocumentAdv>                
<syncfusion:SectionAdv>                   
 <syncfusion:ParagraphAdv>                       
 <syncfusion:SpanAdv Text="This is Span text"/>                   
 </syncfusion:ParagraphAdv>               
 </syncfusion:SectionAdv>           
 </syncfusion:DocumentAdv>       
 </syncfusion:RichTextBoxAdv>
RichTextBoxAdv richtext = new RichTextBoxAdv();          
 DocumentAdv document = new DocumentAdv();           
 SectionAdv section = new SectionAdv();           
 ParagraphAdv paragraph = new ParagraphAdv();           
 SpanAdv span = new SpanAdv();           
 span.Text = "This is span text";           
 paragraph.Inlines.Add(span);           
 section.Blocks.Add(paragraph);           
 document.Sections.Add(section);           
 richtext.Document = document;