Paragraph Alignment and Indentation in WPF RichTextBoxAdv (Classic)

5 May 20211 minute to read

The paragraph alignment and indentation features allow you to define content in paragraphs. They can be added only inside the sections. We can keep n number of paragraphs inside SectionAdv. Each paragraph may contain inline elements such as SpanAdv, HyperlinkAdv, ImageContainerAdv, and UIContainerAdv.

Properties

Property Description Type Data Type
TextAlignment Aligns the paragraph to left, right, center, and justified. Dependency Property TextAlignment
AfterSpacing Changes the spacing between the current paragraph and the next paragraph. Dependency Property Double
BeforeSpacing Changes the spacing between the current paragraph and previous paragraph. Dependency Property Double
LineSpacing Changes the spacing between lines of text. Dependency Property Double
LeftIndent Specifies the indent at the left side of the paragraph. Dependency Property Double
RightIndent Specifies the indent at the right side of the paragraph. Dependency Property Double
ListType Indicates whether the current paragraph is bulleted or numbered. Dependency Property ListType
Inlines Contains the inline elements to be added in the paragraph. Dependency Property InlineCollection

Adding Paragraph Alignment to an Application

ParagraphAdv 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 TextAlignment="Center" AfterSpacing=".3" ListType="Bulleted">                    
</syncfusion:ParagraphAdv>                </syncfusion:SectionAdv>            
</syncfusion:DocumentAdv>        
</syncfusion:RichTextBoxAdv>
     
 RichTextBoxAdv richtext = new RichTextBoxAdv();      
 DocumentAdv document = new DocumentAdv();      
 SectionAdv section = new SectionAdv();      
 ParagraphAdv paragraph = new ParagraphAdv();      
 paragraph.TextAlignment = TextAlignment.Center;     
 paragraph.AfterSpacing = .3;       
 paragraph.ListType = ListType.Bulleted;       
 section.Blocks.Add(paragraph);      
 document.Sections.Add(section);      
 richtext.Document = document;