You seem to have misunderstood the use of the format providers, the data providers and the nature of the issue. Let me elaborate a bit on the whole usage of these items.
1. FormatProviders are meant to be used when you import/export a document to one of the supported formats. For example, they are used in the OpenDocumentCommand and SaveCommand which open/save documents as files on the client machine through the OpenFileDialog and the SaveFileDialog.
2. DataProviders are built on top of FormatProviders in order to enable data-binding. They track when the document content is changed and update the property that they are bound to and vice versa - update the document when the property notifies that it has been changed. The data providers create an instance of the respective format provider internally (HTML, XAML, etc.) and use it to import/export the document.
Now, the code in your snippet that creates a XamlDataProvider, HtmlFormatProvider and RadRichTextBox in code-behind and exports the document to XAML is equivalent to:
RadDocument document =
Since there is no problem with the HTML import, as well as XAML import and export, "document" will be correct and will have all the formatting specified in the initial string. Due to the fact that you are using XamlDataProvider in XAML, the content of the RadRichTextBox will also be correct.
Proceeding with your code, importing MyXaml will just create the same document as the one kept in "document" ("doc" will be the same as "document", correctly preserving the formatting).
Then, when you export the document with the default HTML export, the underlines will be lost again. The value of html at the end will be as in the attached file. As you can see, the style for the underlined span (s_C676007D) does not include an underline.
So, basically, you have two options:
1. Use XamlDataProvider in XAML, just convert the initial input to XAML as in my first snippet.
2. Use HtmlDataProvider in XAML, setting StyleRepositoryExportMode to DontExportStyles, as in the snippet in my previous post.
I hope this helps.
All the best,
the Telerik team
Sharpen your .NET Ninja skills
! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>