Paragraph

The paragraph class allows you to separate the content into paragraphs. It is responsible for displaying inline elements such as Span, HyperlinkRangeStart and End, InlineImage etc. You are also able to configure the appearance of the paragraph by modifying its parameters.

This topic will explain you how to:

Use Paragraphs

The Paragraph can be used only in the context of a Section or a TableCell element. The section exposes a collection of Blocks, to which the paragraphs can be added. This can also be done directly in XAML.

<telerik:RadRichTextBox x:Name="radRichTextBox"> 
    <telerik:RadRichTextBox.Document> 
        <telerik:RadDocument LayoutMode="Paged"> 
            <telerik:Section> 
                <telerik:Paragraph> 
                </telerik:Paragraph> 
                <telerik:Paragraph> 
                </telerik:Paragraph> 
            </telerik:Section> 
        </telerik:RadDocument> 
    </telerik:RadRichTextBox.Document> 
</telerik:RadRichTextBox> 

Section section = new Section(); 
Paragraph paragraph = new Paragraph(); 
section.Blocks.Add( paragraph ); 
RadDocument document = new RadDocument(); 
document.Sections.Add(section); 
 
this.radRichTextBox.Document = document; 
Dim section As New Section() 
Dim paragraph As New Paragraph() 
section.Blocks.Add(paragraph) 
Dim document As New RadDocument() 
document.Sections.Add(section) 
 
Me.radRichTextBox.Document = document 

Add inline elements to a Paragraph

To add inline elements such as Span, HyperlinkRangeStart and End, or InlineImage you have to use the Inlines collection of the Paragraph. In XAML you can directly wrap the inline elements inside the paragraph element.

<telerik:RadRichTextBox x:Name="radRichTextBox"> 
    <telerik:RadDocument> 
        <telerik:Section> 
            <telerik:Paragraph> 
                <telerik:Span Text="Span declared in XAML" /> 
            </telerik:Paragraph> 
        </telerik:Section> 
    </telerik:RadDocument> 
</telerik:RadRichTextBox> 

Section section = new Section(); 
Paragraph paragraph = new Paragraph(); 
Span span = new Span("Span declared in code-behind"); 
paragraph.Inlines.Add( span ); 
section.Blocks.Add( paragraph ); 
RadDocument document = new RadDocument(); 
document.Sections.Add(section); 
 
this.radRichTextBox.Document = document; 
Dim section As New Section() 
Dim paragraph As New Paragraph() 
Dim span As New Span("Span declared in code-behind") 
paragraph.Inlines.Add(span) 
section.Blocks.Add(paragraph) 
Dim document As New RadDocument() 
document.Sections.Add(section) 
 
Me.radRichTextBox.Document = document 

Customize the Paragraph

The Paragraph exposes several properties that allow you to customize the layout of the elements placed underneath it. Here is a list of them:

  • FontSize: Represents the font size of the text inside the Paragraph. If not explicitly set to its child elements, they inherit its value.

  • LineSpacing: Specifies the value for the space between the lines.

  • LineSpacingType: Specifies the type of spacing:

    • AtLeast: The space between the lines should equal or greater than the value of the LineSpacing property.

    • Auto: The space between the lines is determined automatically.

    • Exact: The space between the lines should equal to the value of the LineSpacing property.

  • LeftIndent: Represents the size of the indent to the left size of the Paragraph. The indent gets applied together with the respective margins to the layout.

  • RightIndent: Represents the size of the indent to the right size of the Paragraph. The indent gets applied together with the respective margins to the layout.

  • SpacingAfter: Represents the size of the empty space after the Paragraph.

  • SpacingBefore: Represents the size of the empty space before the Paragraph.

  • TextAlignment: Represents the alignment of the text inside the Paragraph.

  • SuppressLineNumbers: Gets or sets a boolean value indicating whether the line numbering for the current Paragraph is suppressed.

See Also

In this article