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

XamlWriter for RadRichTextBox in RichTextBox

2 Answers 126 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Ruyu
Top achievements
Rank 1
Ruyu asked on 07 Sep 2015, 09:44 AM

 

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);
            sw.WriteLine(data);
            sw.Close();
            fs.Close();

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:

                     <InlineUIContainer>
                        <telerik:RadMaskedTextInput TextMode="PlainText"  />
                    </InlineUIContainer>

           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.

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

         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 Answers, 1 is accepted

Sort by
0
Tanya
Telerik team
answered on 09 Sep 2015, 04:31 PM
Hello ,

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.

Regards,
Tanya
Telerik
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
0
Ruyu
Top achievements
Rank 1
answered on 10 Sep 2015, 01:05 AM
I have checked xamlwriter in msdn and also noticed limitation of it. Thanks for your reply.
Tags
RichTextBox
Asked by
Ruyu
Top achievements
Rank 1
Answers by
Tanya
Telerik team
Ruyu
Top achievements
Rank 1
Share this question
or