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".....)