RadRichTextBox and LightSwitch Newbie Question

I'm creating a LightSwitch project that is designed to move my e-sword study notes to my web site www.MyHebrewBible.Com (MHB). The study notes are in a field thats contains my notes which are formated as RTF. I'm struggling how to use the Telerik RadRichTextBox SilverLight Control this is the main reason for my question.

The database I've created with my LightSwitch App is a collection of rows that I want to process. The table (StudyNote) consists of four fields...

ID: surrogate primary identity key

BCV: (B)ook (C)hapter (V)erse. e.g. "Gen 1:1",

CommentsRTF: My old e-Sword comments that have been persisted in Rich Text Format

CommentsNew: What I want to use to hold my comments that I will eventually add to My Hebrew Bible website. The format (I presume) best fitted for this would be HTML.

I mention this because the samples that I have found on the internet were based on prior versions of LS and things have changed. For example, a Silver Light Custom control can not be inside the LS project. Therefore I had to to create a seperate project which I called RadRichSilverLightClassLibrary. With in that project I created two Silverlight User Controls that utilized the Telerik RadRichTextBox controls.

Here are the steps I took to create this new project.

Deleted the autogenerated Class1.cs file

Added the necessary references

Added a Silverlight User Control called ReadOnlyRtfDocumentViewer

Dragged the RadRichTextBox control onto it and filled out the Wizard

Added a Silverlight User Control called RichTextBoxHtmlDataProvider

Dragged the RadRichTextBox control onto it and filled out the Wizard

For my esword LightSwitch Project, I did the following

Created a Data Source based on the StudyNotes Resource table. This table I created and populated earlier using Sql Server Express 2012.

Created a StudyNotesListDetail screen based on StudyNotes

Changed the ContentRTF control to a custom control

Selected the ReadOnlyRtfDocumentViewer User Control from the RadRichSilverLightClassLibrary Project

Added the same Telerik references that I did to my library project. I'm not sure why this is necessary if the it already has these references. If I didn't add them, then the InitializeComponent method of the user controld would throw a Xaml Parse Exception ... the HtmlDataProvider was not found

QUESTIONS

The way my LightSwitch application stands right now, is that I have not done anything special with the code behind. I didn't do anything else like go into the code behind and wire things up, because I don't know if I'm supposed to or not, or does this all get done declaritively with the Xaml? This is obviously a XAML newbee question. See the attached image.

Right now my study note edit screen has a control for the RTF and empty control for the HTML. I want to also create an copy/paste button that will convert the RTF into HTML and paste into the new control. What I was wondering is if I can just do a batch and convert all the data to HTML and then decide which part of the HTML (if any) I want to keep. This would eliminate the user having to click a copy/paste button. Is this doable?

One of the options is to save RTF data as XAML. It makes sense to have my study notes saved in HTML as that's what I website uses, but what are the advantages of saving data as XAML instead of as HTML?

Iva Toteva

The references that RadRichTextBox uses must be added to all projects that use the control, i.e. the one you declare your custom control and the ones that use it. Sometimes Visual Studio manages this case by adding the dlls that your code depends on behind the scenes (they are copied in the bin/obj folders, even though not explicitly referenced). RadRichTextBox, however, uses MEF to load format providers and does not have a dependency on the format providers. That is why Visual Studio does not handle this case.

As for your other questions:
1. If you have chosen a data provider from the wizard, it should have been added to the XAML. However, you need to set which property the data provider should be bound to, so as to wire the control with the data from the data base. In the attached solution, instead of a data provider, we have used the attached property telerik:XamlDataProvider.Source like this:

telerik:XamlDataProvider.Source="{Binding XamlContent, Mode=TwoWay}"

where XamlContent is the name of the field in the database.

You can use HtmlDataProvider and RtfDataProvider in the same way.

2. If I understand your question correctly, you can convert RTF to HTML programmatically and vice versa. Basically, you can import the content using one of the providers and export the resulting RadDocument to the other format. Information on format providers can be found here.

3. When it comes to the formats, XAML is closest to the internal document model and provides practically lossless persistence. The other formats may have different limitations due to the lack of parallel between the model they have and the document model. For example, you can have headers, footers and comments in RadDocument, but they are not exported to HTML, because HTML has no such concept.

Progress, Telerik, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks or appropriate markings.