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

loading standard xaml

3 Answers 222 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Laura
Top achievements
Rank 1
Laura asked on 16 Mar 2011, 09:23 PM
I am trying to load a standard xaml file into the RichTextBox and I am getting an exception when I do the import function.  The exception I am getting is:
"Unable to cast object of type 'System.Windows.Documents.FlowDocument' to type 'Telerik.Windows.Documents.Model.RadDocument'."

The file I am trying to import is:
 

<FlowDocument
  xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'
  xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'>
  <Paragraph FontFamily="Calibri" FontWeight="Bold" FontSize="24">
    WPF Flow Documents</Paragraph>
  <Paragraph>WPF Flow Documents are <Italic>quite sophisticated</Italic>.
    They support all common layout options, as well as many you probably
    do <Span Foreground="Red">not expect</Span>.</Paragraph>
  <List>
    <ListItem><Paragraph>First List Item</Paragraph></ListItem>
    <ListItem><Paragraph>Second List Item</Paragraph></ListItem>
    <ListItem><Paragraph>Third List Item</Paragraph></ListItem>
  </List>
  <Paragraph>Of course, Flow Documents also support the definition
    of <Bold><Span FontFamily="Comic Sans MS" FontSize="24"
    Foreground="Blue">in line</Span></Bold> font sizes and font faces.
  </Paragraph>
</FlowDocument>

 

My code is:

FileStream

 

 

xamlInStream = new FileStream(@"C:\testimport.xaml",FileMode.Open,FileAccess.Read);

 

 

 

 

XamlFormatProvider xamlFormatProvider = new XamlFormatProvider();

 

 

 

RadDocument radDocument = xamlFormatProvider.Import(xamlInStream);

 

 

editor.Document = radDocument;


What do I need to do to open standard xaml files.  Also, I noticed that when documents are saved as xaml documents the file format is of a RadDocument, is there a way to get a standard FlowDocument from the text box?

3 Answers, 1 is accepted

Sort by
0
Andrew
Telerik team
answered on 17 Mar 2011, 10:03 AM
Hi Laura,

I see the XAML you are trying to import into RadRichTextBox is MS RichTextBox specific, and that's the reason why the XamlFormatProvider won't do the job. If this is the XAML you want to import you can use our Telerik.Windows.Documents.FormatProviders.MsRichTextBoxXaml. This is a provider, which we introduced in our Q1 2011 Beta, that can convert the XAML from MS RichTextBox to RadDocument and vice versa.
If you have other question do not hesitate to contact us.

All the best,

Andrew
the Telerik team

0
Oliver Weichhold
Top achievements
Rank 1
answered on 26 Mar 2011, 08:24 PM
I can't find the MsRichTextBoxXaml provider in the Q1 2011 release. Was it removed?
0
Ivailo Karamanolev
Telerik team
answered on 29 Mar 2011, 10:11 AM
Hello Oliver Weichhold,

The MsRichTextBoxXaml is currently only available for Silverlight. We might also introduce it for WPF, but there is nothing specific about that yet.

Regards,
Ivailo
the Telerik team
Tags
RichTextBox
Asked by
Laura
Top achievements
Rank 1
Answers by
Andrew
Telerik team
Oliver Weichhold
Top achievements
Rank 1
Ivailo Karamanolev
Telerik team
Share this question
or