loading xml in RichTextBox

13 posts, 0 answers
  1. Gauri
    Gauri avatar
    25 posts
    Member since:
    Jun 2010

    Posted 28 Sep 2010 Link to this post

    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?
  2. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 29 Sep 2010 Link to this post

    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
  3. DevCraft banner
  4. Gauri
    Gauri avatar
    25 posts
    Member since:
    Jun 2010

    Posted 01 Oct 2010 Link to this post

    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.
  5. Ivailo Karamanolev
    Admin
    Ivailo Karamanolev avatar
    276 posts

    Posted 01 Oct 2010 Link to this post

    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
  6. Angeli
    Angeli avatar
    29 posts
    Member since:
    Apr 2011

    Posted 09 May 2011 Link to this post

    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.


  7. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 12 May 2011 Link to this post

    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
  8. Angeli
    Angeli avatar
    29 posts
    Member since:
    Apr 2011

    Posted 12 May 2011 Link to this post

    thanks so much for your quick response. it works great. :)
  9. Jon
    Jon avatar
    5 posts
    Member since:
    Jul 2010

    Posted 27 Nov 2012 Link to this post

    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?
  10. Petya
    Admin
    Petya avatar
    975 posts

    Posted 29 Nov 2012 Link to this post

    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.

  11. Jon
    Jon avatar
    5 posts
    Member since:
    Jul 2010

    Posted 29 Nov 2012 Link to this post

    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
  12. Todd
    Todd avatar
    12 posts
    Member since:
    Jul 2008

    Posted 14 May 2013 Link to this post

    This sample totally doesn't work on the latest build.
  13. Petya
    Admin
    Petya avatar
    975 posts

    Posted 17 May 2013 Link to this post

    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.

  14. Todd
    Todd avatar
    12 posts
    Member since:
    Jul 2008

    Posted 17 May 2013 Link to this post

    This works perfectly!  Thank you!
Back to Top
DevCraft banner