This is a migrated thread and some comments may be shown as answers.

RichTextBox content to xaml in memory stream

3 Answers 214 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Edo Cof
Top achievements
Rank 1
Edo Cof asked on 04 May 2010, 07:06 PM
                IDocumentFormatProvider exporter = new XamlFormatProvider(); 
                MemoryStream output = new MemoryStream(); 
                exporter.Export(this.editor.Document, output); 
                StreamReader stream = new StreamReader(output); 
                return stream.ReadToEnd(); 
I try this way, but after Export called, i check ouput variable and get error: Cannot access a closed Stream for every property that Stream has.
I want to store xaml in database, and the best way is to store it with RIA in mssql Text field (i think).

3 Answers, 1 is accepted

Sort by
0
Alex
Telerik team
answered on 05 May 2010, 08:59 AM
Hi Edo Cof,

We are very glad you decided to give a spin of our new control. 

Currently the Export method of the XamlFormatProvider class disposes the output stream that it takes as a parameter. This is a known issue and will be fixed in the next release. For now we can suggest a temporary workaround by using a custom StringStream class. Here is a snippet for getting the XAML content of the document:

IDocumentFormatProvider exporter = new XamlFormatProvider();
string result;
 
using (StringStream output = new StringStream())
{
    exporter.Export(document, output);
    result = output.Value;
}
 
return result;


Please find the StringStream class in the attached .zip file.
Let us know if you need further assistance.

Regards,
Alex
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Malcolm
Top achievements
Rank 1
answered on 17 Sep 2010, 11:35 AM
Is there a typo here?

 public string Value
        {
            get
            {
                return this.value;
            }
        }

should it actually be

public string Value
        {
            get
            {
                PrepareValue();
                return this.value;
            }
        }

otherwise the this.value doesn't get set first
0
Mike
Telerik team
answered on 17 Sep 2010, 01:12 PM
Hello Malcolm,

The purpose of the code we posted several months ago was to workaround an issue related XamlFormatProvider closing the output stream. This problem has been fixed in Q2 version and you would no longer need to use this helper class. Let us know if this helps.

Sincerely yours,
Mike
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
RichTextBox
Asked by
Edo Cof
Top achievements
Rank 1
Answers by
Alex
Telerik team
Malcolm
Top achievements
Rank 1
Mike
Telerik team
Share this question
or