Getting XAML from RadRichtexBox without own code?

8 posts, 1 answers
  1. prog1
    prog1 avatar
    61 posts
    Member since:
    Jul 2008

    Posted 30 Jul 2010 Link to this post

    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.
  2. Answer
    Ivailo Karamanolev
    Admin
    Ivailo Karamanolev avatar
    276 posts

    Posted 30 Jul 2010 Link to this post

    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
  3. DevCraft banner
  4. Vit100
    Vit100 avatar
    66 posts
    Member since:
    Oct 2012

    Posted 06 Aug 2010 Link to this post

    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.
  5. Vit100
    Vit100 avatar
    66 posts
    Member since:
    Oct 2012

    Posted 06 Aug 2010 Link to this post

    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();
    }
  6. Javier
    Javier avatar
    1 posts
    Member since:
    Aug 2012

    Posted 06 Aug 2010 Link to this post

    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!!!!!!!!

     

     

     

  7. Ivailo Karamanolev
    Admin
    Ivailo Karamanolev avatar
    276 posts

    Posted 10 Aug 2010 Link to this post

    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
  8. Bhushan
    Bhushan avatar
    3 posts
    Member since:
    Sep 2010

    Posted 01 Sep 2010 Link to this post

    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
  9. Boby
    Admin
    Boby avatar
    595 posts

    Posted 03 Sep 2010 Link to this post

    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
Back to Top
DevCraft banner