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

Getting XAML from RadRichtexBox without own code?

7 Answers 132 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
prog1
Top achievements
Rank 1
prog1 asked on 30 Jul 2010, 04:04 PM
Is there any possibility to get the Text from a RadRichTextBox withour own code?

I read this about RadRichtextBox:
Documentation

Now I wanted to know if RadRichtexBox or even RadDocument could expose properties like:

RadRichtexBox1.TextAsXAML
RadDocument 1.DocumentAsHTML

Are ther any plans to do that? Even a method for code behind would be nice.

7 Answers, 1 is accepted

Sort by
0
Accepted
Ivailo Karamanolev
Telerik team
answered on 30 Jul 2010, 05:04 PM
Hi Fabian Höger,

We are currently developing some new supplementary components for our FormatProviders that will expose properties like Xaml, Html, Text and that will enable binding directly in (with no code-behind). This feature will be part of the Q2 SP1 release, which is coming in a couple of weeks.

Until then, you can still use the TxtFormatProvider if you want plain text, or XamlDataProvider and HtmlDataProvider for XAML and HTML respectively to import/export RadRichTextBox contents. Let us know if you need any further assistance.

Greetings,
Ivailo
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
Vit100
Top achievements
Rank 1
answered on 06 Aug 2010, 06:11 PM

Looks like TxtFormatProvider doesn't work.

...
   <telerik:RadRichTextBox Grid.Column="2" Background="White" x:Name="rich" />
.....

using Telerik.Windows.Documents.FormatProviders.Html;
using Telerik.Windows.Documents.FormatProviders.Txt;
..
  
 private void button1_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            IDocumentFormatProvider pp = new TxtFormatProvider();
            using (MemoryStream output = new MemoryStream())
            {
                pp.Export(rich.Document, output); <<-Stream is always empty..
                output.Seek(0, SeekOrigin.Begin);
                using (StreamReader reader = new StreamReader(output))
                { var s= reader.ReadToEnd();                 }
            }
  
        }

If in the example above TxtFormatProvider() replaced by HtmlFormatProvider() everything is OK.
0
Vit100
Top achievements
Rank 1
answered on 06 Aug 2010, 07:26 PM
So more detailed investigation showed that in your code there is small bug...
This is what you do in your code:

public void Export(RadDocument document, Stream output)
{
    DocumentSelection selection = new DocumentSelection(document);
    selection.SelectAll();
    new StreamWriter(output).Write(selection.GetSelectedText());
}

Where is Flush() ?? -))
should be something like this:
public void Export(RadDocument document, Stream output)
{
    DocumentSelection selection = new DocumentSelection(document);
    selection.SelectAll();
    new StreamWriter(output).Write(selection.GetSelectedText()).Flush();
}
0
Javier
Top achievements
Rank 1
answered on 06 Aug 2010, 10:48 PM
Hi.!!

I have Q2 2010 and I try to export my document to text plain . but i can´t. can you help me.

public

 

 

string ExportToTXT(RadDocument document)

 

{

 

 

 

 

 

 

 

IDocumentFormatProvider provider = new TxtFormatProvider();

 

 

 

 

string exportValue = String.Empty;

 

 

 

 

using (MemoryStream output = new MemoryStream())

 

{

provider.Export(document, output);

output.Seek(0,

 

 

SeekOrigin.Begin);

 

 

 

 

using (StreamReader reader = new StreamReader(output))

 

{

exportValue = reader.ReadToEnd();

}

}

 

 

 

return exportValue;

 

}

Thank`s!!!!!!!!

 

 

 

0
Ivailo Karamanolev
Telerik team
answered on 10 Aug 2010, 05:05 PM
Hi Javier,

There was an issue with the TxtFormatProvider not flushing the output stream until it's closed which affects cases like yours. We have fixed it and the fix will be available in Q2 SP1 coming this week. As a workaround, you can use the following snippet:
public string ExportToTXT(RadDocument document) {
    DocumentSelection selection = new DocumentSelection(document);
    selection.SelectAll();
    return selection.GetSelectedText();
}
Let us know if you have any further questions.

All the best,
Ivailo
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
Bhushan
Top achievements
Rank 1
answered on 01 Sep 2010, 03:09 PM
Hi,

Can anyone help me regarding converting the inserted custom controls in to the rich textbox in to HTML.
And provide me if you have any source code.

Thanks,
Bhushan
0
Boby
Telerik team
answered on 03 Sep 2010, 02:41 PM
Hi Bhushan,
Please refer to the answer in this thread.

Kind regards,
Boby
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
prog1
Top achievements
Rank 1
Answers by
Ivailo Karamanolev
Telerik team
Vit100
Top achievements
Rank 1
Javier
Top achievements
Rank 1
Bhushan
Top achievements
Rank 1
Boby
Telerik team
Share this question
or