Class
DocumentFragment

Represents a fragment of a document that can contain various types of content, including text, images, and other document elements. This structure is used for holding a portion of a document for manipulation or transfer.

Definition

Namespace:Telerik.Windows.Documents.Model

Assembly:Telerik.Windows.Controls.RichTextBox.dll

Syntax:

cs-api-definition
public class DocumentFragment

Inheritance: objectDocumentFragment

Constructors

DocumentFragment(DocumentSelection)

Initializes a new instance of the DocumentFragment class.

Declaration

cs-api-definition
public DocumentFragment(DocumentSelection documentSelection)

Parameters

documentSelection

DocumentSelection

The document selection to be added to the fragment.

DocumentFragment(DocumentSelection, bool)

Initializes a new instance of the DocumentFragment class.

Declaration

cs-api-definition
public DocumentFragment(DocumentSelection documentSelection, bool includeNonCopyableAnnotationMarkers)

Parameters

documentSelection

DocumentSelection

selection

includeNonCopyableAnnotationMarkers

bool

If true result fragment will contain non-copyable elements like read-only and permission ranges. Otherwise these elements will be removed from the result fragment.

DocumentFragment(RadDocument)

Initializes a new instance of the DocumentFragment class.

Declaration

cs-api-definition
public DocumentFragment(RadDocument document)

Parameters

document

RadDocument

The document to be added to the fragment.

Properties

IsEmpty

Gets a value indicating whether the fragment is empty.

Declaration

cs-api-definition
public bool IsEmpty { get; }

Property Value

bool

true if the fragment is empty; otherwise, false.

IsLastParagraphClosed

Gets or sets a value indicating whether the fragment ends with full empty paragraph.

Declaration

cs-api-definition
public bool IsLastParagraphClosed { get; set; }

Property Value

bool

true if the fragment ends with full empty paragraph; otherwise, false.

Methods

CreateFromInline(Inline)

Creates a fragment from Inline.

Declaration

cs-api-definition
public static DocumentFragment CreateFromInline(Inline inline)

Parameters

inline

Inline

The Inline to add to the fragment.

Returns

DocumentFragment

EnumerateChildrenOfType<T>()

Enumerates all children of a specified type.

Declaration

cs-api-definition
public IEnumerable<T> EnumerateChildrenOfType<T>() where T : DocumentElement

Returns

IEnumerable<T>

A collection from the children of the specified type.

GetText()

Converts the fragment to plain text.

Declaration

cs-api-definition
public string GetText()

Returns

string

String containing the text representation of the document.

ToDocument()

Converts to this instance to a RadDocument.

Declaration

cs-api-definition
public RadDocument ToDocument()

Returns

RadDocument

The RadDocument generated from the current instance.