Back to Devexpress

RichEditControl.LoadDocumentTemplate(Stream) Method

wpf-devexpress-dot-xpf-dot-richedit-dot-richeditcontrol-dot-loaddocumenttemplate-x28-system-dot-io-dot-stream-x29.md

latest3.2 KB
Original Source

RichEditControl.LoadDocumentTemplate(Stream) Method

Loads a document template from the stream.

Namespace : DevExpress.Xpf.RichEdit

Assembly : DevExpress.Xpf.RichEdit.v25.2.dll

NuGet Package : DevExpress.Wpf.RichEdit

Declaration

csharp
public virtual bool LoadDocumentTemplate(
    Stream stream
)
vb
Public Overridable Function LoadDocumentTemplate(
    stream As Stream
) As Boolean

Parameters

NameTypeDescription
streamStream

A Stream object that is the stream used to load a document.

|

Returns

TypeDescription
Boolean

true, if the document is successfully loaded; otherwise, false.

|

Remarks

The document template cannot be automatically overwritten either in code or in the UI. The information about the original file location and its format is dropped. An attempt to save (i.e., overwrite) the original document invokes the Save As dialog that enables the end-user to specify a different file name and format.

The source stream can be non-seekable. In this case, the stream is buffered automatically. After loading the document, the stream remains open.

The format of the document loaded from a stream is detected automatically by the built-in IFormatDetectorService service implementation. If the format detection fails or the passed stream is null , the RichEditControl.InvalidFormatException event fires.

Determine a moment when the document model can be safely modified using the RichEditControl.DocumentLoaded event. Call the LoadDocumentTemplate method in the Form.Loaded event handler to work with the DocumentLoaded event. Handle the DocumentLayout.DocumentFormatted event to check the loaded document’s layout.

Tip

Use LoadDocumentTemplate method overloads which explicit format definition to improve performance.

See Also

Troubleshooting

RichEditControl Class

RichEditControl Members

DevExpress.Xpf.RichEdit Namespace