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 reference the Telerik.WinControls.RichTextEditor.dll and add the following namespace:

  • Telerik.WinForms.Documents.FormatProviders.Xaml

Import Settings

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

The first example shows how to use XamlFormatProvider to import XAML document from a file.

Import XAML Document from a File

XamlFormatProvider xamlformatProvider = new XamlFormatProvider();
using (Stream stream = File.OpenRead(@"..\..\RichTextEditor\ImportExport\Sample.xaml"))
{
    this.radRichTextEditor1.Document = xamlformatProvider.Import(stream);
}

Dim provider As XamlFormatProvider = New XamlFormatProvider()
Using output As FileStream = File.OpenWrite("Sample.xaml")
    Dim document As RadDocument = Me.radRichTextEditor1.Document
    provider.Export(document, output)
End Using

Export Settings

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

This example shows how to use XamlFormatProvider to export RadDocument to a file.

Export Document to a File

XamlFormatProvider provider = new XamlFormatProvider();
using (FileStream output = File.OpenWrite("Sample.xaml"))
{
    RadDocument document = this.radRichTextEditor1.Document;
    provider.Export(document, output);
}

Dim xamlformatProvider As XamlFormatProvider = New XamlFormatProvider()
Using inputStream As FileStream = File.OpenRead("..\..\RichTextEditor\ImportExport\Sample.xml")
    Me.radRichTextEditor1.Document = xamlformatProvider.Import(inputStream)
End Using

See Also

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

Give article feedback

Tell us how we can improve this article

close
Dummy