I am not able to Retrieve text from "RichTextBox". While using the following piece of code it returns Empty string.
and the following code also returns Empty string.
The version of Framework would be "2011.1.609.0"
Thanks in advance,
3 Answers, 1 is accepted
The Silverlight RichTextBox is tricky to work with. This control is a "container" type of control meaning it contains other "block" elements, usually the Paragraph or Section. Its these block elements that hold the actual text displayed in the RichTextBox. Thus to fetch the text that is being displayed you must enumerate through the individual blocks and fetch the text from each block element.
To make matters worse the contents of the RichTextBox are not contained in the Silverlight Visual Tree. You have to get the Xaml property and parse the contents yourself. Let's look at a real example... let's assume that you have this in the XAML file for your Silverlight application:
Running your application will show text like that shown in the attached screenshot. However in DOM Explorer all you see is this:
Notice that there's no text in the DOM view even though it is specified in the XAML and even displayed in the application. We have to use code to fetch the XAML that the RichTextBox holds as data then parse out the text buried in it and do whatever we want from there. Here's an example:
the Telerik team
Thanks alot for the great example!
I used it with WebAii with 2011.1.712.0 and it works fine. But after migration to WebAii 2011.2.1413.0 it does not work.
I have following code
Before (WebAii 2011.1.712.0) runNodes contained several elements. For now (WebAii 2011.2.1413.0) it contains only one element.
Was something changed in RichTextBox handling ?
Should I mention that we migrated our application from Silverlight 4 to Silverlight 5. May be the reason is the version of Silverlight?
So, in my code presented below, I just replaced the last line with
Now it works for me.