XamlWriter for RadRichTextBox in RichTextBox

3 posts, 0 answers
  1. Ruyu
    Ruyu avatar
    3 posts
    Member since:
    Jan 2015

    Posted 07 Sep 2015 Link to this post


    The simple Rad controls can be processed by System.Windows.Markup.XamlWriter correctly, but when process the RadRichTextBox, "stackoverflow" occured.

    I have made the following test:

    1.Create a buttton and a normal RichTextBox with name "richTextBox"

    2.Write the following codes in the click event of the button

                string data = System.Windows.Markup.XamlWriter.Save(richTextBox.Document);
                FileStream fs = new FileStream("C:/TEST.XAML", FileMode.Create);
                StreamWriter sw = new StreamWriter(fs);

    3.Add the Telerik InlineContainer in to richtextbox and click the button to save the flowdocument into xaml file.

          For the simple controls like Radbutton or RadMaskedTextInput , it's okay:

               Add the following codes in desgine screen:

                            <telerik:RadMaskedTextInput TextMode="PlainText"  />

               Got the result:

                  <FlowDocument PagePadding="5,0,5,0" AllowDrop="True" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"><Paragraph><telerik:RadMaskedTextInput Value="asdaasdasd" OriginalValue="{x:Null}" SelectionLength="0" SelectionStart="10" Text="asdaasdasd" TextMode="PlainText" IsEmpty="False" HasErrors="False"><telerik:RadMaskedTextInput.CopyCommand><telerik:DelegateCommand /></telerik:RadMaskedTextInput.CopyCommand><telerik:RadMaskedTextInput.ClearCommand><telerik:DelegateCommand /></telerik:RadMaskedTextInput.ClearCommand><telerik:RadMaskedTextInput.CutCommand><telerik:DelegateCommand /></telerik:RadMaskedTextInput.CutCommand><telerik:RadMaskedTextInput.PasteCommand><telerik:DelegateCommand /></telerik:RadMaskedTextInput.PasteCommand></telerik:RadMaskedTextInput></Paragraph></FlowDocument>


            Then, for the RadRichTextBox,  it can be shown in RichTextBox correctly.

                            <telerik:RadRichTextBox x:Name="radRichTextBox" Height="100" Width="120" />

             But  it failed to saved as xaml with "System.StackOverflowException" 

             Is there any workaround?

             (I used to insert RadRichTextBox into RadRichTextBox, but it also has the cursor problem as my another thread "Cursor Focus problem of TextBox in RadRichTextBox".....)


  2. Tanya
    Tanya avatar
    376 posts

    Posted 09 Sep 2015 Link to this post

    Hello Ruyu,

    I am not sure I properly understand your scenario. Could you explain in more details? 

    Generally speaking, when exporting InlineUIContainer objects to XAML we recommend subscribing to the Export events of the XamlFormatProvider and serialize them manually. This is due to the fact that the XamlWriter is not always able to do this automatically for complex controls.

    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 Feedback Portal and vote to affect the priority of the items
  3. DevCraft R3 2016 release webinar banner
  4. Ruyu
    Ruyu avatar
    3 posts
    Member since:
    Jan 2015

    Posted 09 Sep 2015 in reply to Tanya Link to this post

    I have checked xamlwriter in msdn and also noticed limitation of it. Thanks for your reply.
Back to Top