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

Adding UIElementContainer to RadRichTextBox

1 Answer 77 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Joseph
Top achievements
Rank 1
Joseph asked on 14 Jan 2011, 10:53 AM
Telerik.Windows.Documents.Model.InlineUIContainer cont = new Telerik.Windows.Documents.Model.InlineUIContainer();
Telerik.Windows.Documents.Model.Span block = new Telerik.Windows.Documents.Model.Span();
 
block.Text = "Hello World";
 
cont.Children.Add(block);
Telerik.Windows.Documents.Model.Section s = new Telerik.Windows.Documents.Model.Section();
Telerik.Windows.Documents.Model.Paragraph p = new Telerik.Windows.Documents.Model.Paragraph();
 
p.Children.Add(cont);
 
s.Children.Add(p);
 
rt.RadRichTextBox1.Document.Sections.Add(s);
 
this.LayoutRoot.Children.Add(rt);



I am getting the following error : 
Unable to cast object of type 'Telerik.Windows.Documents.DocumentStructure.BoxNode' to type 'Telerik.Windows.Documents.DocumentStructure.BoxStartNode'.

1 Answer, 1 is accepted

Sort by
0
Iva Toteva
Telerik team
answered on 18 Jan 2011, 09:02 AM
Hello Joseph,

 InlineUIContainers are used when you want to embed UIElements in RadRichTextBox. Spans are not UIElements and there is no reason to use InlineUIContainers to add a Span to the document. You can do that like this:

Section section = new Section();
 
Paragraph paragraph = new Paragraph();
section.Blocks.Add(paragraph);
 
Span span = new Span("Hello World");
paragraph.Inlines.Add(span);
 
this.RadRichTextBox1.Document.Sections.Add(section);

If you have any other questions, do not hesitate to contact us again.


Kind regards,
Iva
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
Tags
RichTextBox
Asked by
Joseph
Top achievements
Rank 1
Answers by
Iva Toteva
Telerik team
Share this question
or