Highlight text

10 posts, 1 answers
  1. Philipp
    Philipp avatar
    12 posts
    Member since:
    Jan 2013

    Posted 19 Dec 2013 Link to this post

    Dear telerik-team,

    I want to highlight and scroll to parts of a text inside a readonly RichTextBox via code. Is that possible?

    For example: I've a RichtextBox with three pages. First page content is "one", second content is "two" and third content is "three". I want to highlight "two" and scroll to the content.

    Kind regards,
    Philipp
  2. Yancho
    Admin
    Yancho avatar
    72 posts

    Posted 20 Dec 2013 Link to this post

    Hi Philipp,

    Thank you for contacting us!

    I've attached a small running example to illustrate to you how to achieve your goal.

    Please, let me know if you have any other comments or questions. I would be glad to provide any assistance.

    Kind regards,

    Yancho
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. UI for WPF is Visual Studio 2017 Ready
  4. Philipp
    Philipp avatar
    12 posts
    Member since:
    Jan 2013

    Posted 06 Jan 2014 Link to this post

    Hi Yancho,

    I can't open the project because I only got VisualStudio 2010. I tried to create a 2010 project and used the MainWindow.xaml from your project but the EditingContextTypeToBoolConverter is not available. Do you have any suggestions?

    Update: I downloaded the latest trial version and now I'm able to start the demo. Is there no other way then using the textsearch? And is there a way to scroll to the text if I have a multi-page document?

    Kind regards,
    Philipp
  5. Yancho
    Admin
    Yancho avatar
    72 posts

    Posted 08 Jan 2014 Link to this post

    Hi Philipp,

    Could you please give us more details about your desired scenario? This way we are going to propose a solution to fit your needs.

    As to scrolling, the ScrollToVerticalOffset() method used in the project should do the trick, are you facing troubles with this?

    Looking forward to your reply.

    All the best, Yancho
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  6. Philipp
    Philipp avatar
    12 posts
    Member since:
    Jan 2013

    Posted 08 Jan 2014 Link to this post

    Hi Yancho,

    I have to highlight complete "textblocks" including more then one line. 
    When I select the text via mouse it looks like in the first picture in the attached file. It would be nice if the highlighted area would be one square like in the second picture. Maybe with an overlay or something else.

    And is it possible to select/highlight the text from a viewmodel?

    Kind regards,
    Philipp
  7. Yancho
    Admin
    Yancho avatar
    72 posts

    Posted 09 Jan 2014 Link to this post

    Hi Philipp,

    It is possible to accomplish the desired effect from the second picture if you change the paragraph's background color property or if you create a custom UI Layer. A UI Layer gives you the ability to customize the presentation of different parts of the document. More information about this you can find in this article, as well as in this example.

    If you follow the MVVM design pattern, you can try using RadDocumentEditor. Also you need to use the RadRichTextBox’s Data Providers which wrap the FormatProviders' functionality and allow its usage in XAML without any code-behind. You can find more information in the following articles: RadDocumentEditor and Data Providers. Please, take a look at this demo project for a reference!

    Let me know, if I can provide any further assistance. 

    Kind regards,
    Yancho
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  8. Philipp
    Philipp avatar
    12 posts
    Member since:
    Jan 2013

    Posted 10 Jan 2014 Link to this post

    Hi Yancho,

    thank you for the highlight example. That's what I was locking for.

    I know about the DataProviders but I don't know how to use a RadDocumentEditor in my viewmodel cause I thought I can only bind string properties to the DataProvider and the RadDocumentEditor needs a RadDocument as constructor parameter.

    Kind regards,
    Philipp
  9. Yancho
    Admin
    Yancho avatar
    72 posts

    Posted 13 Jan 2014 Link to this post

    Hi Philipp,

    Please, take a look at this forum post. There is a code-snippet which explains how you could use a RadDocumentEditor in your viewmodel.

    I hope this would help you!
    If you have any further questions, do not hesitate to contact us. 

    All the best,
    Yancho
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  10. Philipp
    Philipp avatar
    12 posts
    Member since:
    Jan 2013

    Posted 14 Jan 2014 Link to this post

    Hi Yancho,

    my maingoal is to select text from my viewmodel without any code behind. When I use a RadDocumentEditor (like you mentioned with Import and Export) I still have to bind a string property to my view. How is it possible that this will help me to select something without using code behind? Or is the selection info stored in the e.g. xaml-string I bind with a XamlDataProvider?

    Kind regards,
    Philipp
  11. Answer
    Petya
    Admin
    Petya avatar
    975 posts

    Posted 16 Jan 2014 Link to this post

    Hello Philipp,

    As I said in the other forum thread on the matter, selection is considered part of the UI and not the document content which is why accessing it from your view model is not possible. The approach I'd recommend is to use code-behind.

    Let us know if you have any other inquiries.

    Regards,
    Petya
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top
UI for WPF is Visual Studio 2017 Ready