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

loading xml in RichTextBox

12 Answers 312 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Gauri
Top achievements
Rank 1
Gauri asked on 28 Sep 2010, 12:30 PM
Hello,
I have to load XML file in my application. I am using RichTextbox.
How to load the xml file in RichTextbox? And I am also generating treeview from that xml file.Then I want to highlight corresponding xml node in RichTextbox when I click on treeview item. Can anyone help me?

12 Answers, 1 is accepted

Sort by
0
Iva Toteva
Telerik team
answered on 29 Sep 2010, 01:24 PM
Hello Gauri,

As I understand you, your editor and TreeView will be read-only and for this case we have prepared you a demo project which shows how your scenario can be implemented. We have used the TreeView from the Silverlight SDK and our RadDocument API. The functionality which is available is:
  • When the user selects an item from the TreeView, the corresponding section of the XML file is highlighted in the editor.
  • When the user moves the caret position inside the editor, the corresponding section is highlighted and the TreeViewItem is selected.
I have attached the project and we'll be glad to hear how it goes.
Let us know if you have any issues and/or feedback.

All the best,
Iva
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
0
Gauri
Top achievements
Rank 1
answered on 01 Oct 2010, 07:17 AM
Thanks for the answer.
And RichTextBox must contain the XML with all color formatting. But XML file should be generik. And I am using WCF to load XML in RichTextbox. So can you please help me doing this.
Thanks in advance.
0
Ivailo Karamanolev
Telerik team
answered on 01 Oct 2010, 11:47 AM
Hello Gauri,

Unfortunately, such a demo is not available at the moment. The functionality you requested is demonstrated in the demos on the site (as it goes to syntactic coloring) and the project we already sent you (for dynamically changing the document based on the selection). I'd recommend you try to try implementing the application and get back to us if you experience any specific issues.

Best wishes,
Ivailo
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
0
Angeli
Top achievements
Rank 1
answered on 09 May 2011, 03:45 PM
Hi Iva!

i downloaded the source code you gave, 352301-xmlviewer.zip, but it seems to produce a few errors. how do i fix these?
the sample you gave is a really great help to the project i'm currently working on. i hope to hear from you soon.


0
Iva Toteva
Telerik team
answered on 12 May 2011, 09:07 AM
Hi Angeli,

The demo was prepared to work with the version of the controls at the time - Q2 or one of the service packs after that. We have had two major releases after that and some breaking changes have been introduced.
Please find attached a modified version of the demo, adjusted to work with the assemblies from Q1 2011 (2011.1 315) or the service pack (2011.1 419).
I hope that helps.

Best wishes,
Iva
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
0
Angeli
Top achievements
Rank 1
answered on 12 May 2011, 03:28 PM
thanks so much for your quick response. it works great. :)
0
Jon
Top achievements
Rank 1
answered on 27 Nov 2012, 11:33 PM
Do the data providers give any syntax highlighting?  Let's say I want to databind the document property of the RichTextBox to a string xml document, but then give it syntax highlighting.  This must be done through databinding (i.e. the RichTextBox MUST be bound to a data provider that is getting a string of XML data (may not be perfectly formatted, so you cannot rely on it being convertable to an XMLDocument) then syntax highlight the XML properly).  Is this possible?  So far all I've seen is manually syntax highlighting a document in the view, then setting the RichTextBox.Document directly on the view, or databinding to a string that is syntax highlighting itself via some sort of markup.  It would be nice to say "Hey, here's a string of XML, highlight it like it's XML."  Again, is this possible?
0
Petya
Telerik team
answered on 29 Nov 2012, 04:48 PM
Hi Jon,

RadRichTextBox is a rich-text editor, and not a code editor and format providers are implemented in order to serialize/deserialize valid content to/from the supported by the control formats. At this point we are not considering implementing syntax highlighting as this is not really a case we target to support out of the box.

However, RadRichTextBox is highly extensible, so if you wish to implement syntax highlighting, you can look through the previously referenced demo for guidelines. Since you prefer the solution to be implemented with data-binding, you can try creating your own format provider which will take care of your custom requirements. However, you should test the performance of the control to see if it fits your requirements, as run-time syntax-highlighting may take its toll.

Please let us know if you need additional assistance.
 
Regards,
Petya
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Jon
Top achievements
Rank 1
answered on 29 Nov 2012, 05:10 PM
Hey Petya,

Thanks for the response.  I have decided to use competitive product as it has a clean approach to DataBinding as well as syntax highlighting.  Thanks again.

-Jon
0
Todd
Top achievements
Rank 1
answered on 14 May 2013, 04:18 PM
This sample totally doesn't work on the latest build.
0
Petya
Telerik team
answered on 17 May 2013, 11:01 AM
Hello Todd,

The initial demo Iva uploaded might not work as some changes have been introduced since 2010.

However, I downloaded this one and after I upgraded the project to Silverlight 5 (due to the discontinued support for Silverlight 4) and referenced our latest official Q1 2013 SP1 version, it works as expected. I am also attaching the modified project for your reference.

Let us know if you are still having difficulties.
 
All the best,
Petya
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Todd
Top achievements
Rank 1
answered on 17 May 2013, 01:48 PM
This works perfectly!  Thank you!
Tags
RichTextBox
Asked by
Gauri
Top achievements
Rank 1
Answers by
Iva Toteva
Telerik team
Gauri
Top achievements
Rank 1
Ivailo Karamanolev
Telerik team
Angeli
Top achievements
Rank 1
Jon
Top achievements
Rank 1
Petya
Telerik team
Todd
Top achievements
Rank 1
Share this question
or