Edit this page

Using XamlFormatProvider

XamlFormatProvider makes it easy to import and export RadDocument to/from XAML format, preserving as much as possible of the document structure and formatting.

To use XamlFormatProvider, you should add a reference to:

  • Telerik.Windows.Documents.FormatProviders.Xaml.dll

Import Settings

In order to import a XAML document you can use the overloads of the Import() method.

Example 1 shows how to use XamlFormatProvider to import XAML document from a file.

Example 1: Import XAML document from a file

XamlFormatProvider xamlformatProvider = new XamlFormatProvider();
using (FileStream inputStream = new FileStream("XamlDocument.xml",FileMode.Open))
    this.radRichTextBox.Document = xamlformatProvider.Import(inputStream);

Export Settings

In order to export a document to XAML, you need to use the Export() method of XamlFormatProvider.

Example 2 shows how to use XamlFormatProvider to export RadDocument to a file.

Example 3: Export document to a file

XamlFormatProvider provider = new XamlFormatProvider();
using (FileStream output =  new FileStream("XamlDocument.xml",FileMode.OpenOrCreate))
    RadDocument document = this.radRichTextBox.Document;
    provider.Export(document, output);

See Also

Is this article helpful? Yes / No
Thank you for your feedback!

Give article feedback

Tell us how we can improve this article