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

Highlight text

9 Answers 508 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Philipp
Top achievements
Rank 1
Philipp asked on 19 Dec 2013, 01:13 PM
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

9 Answers, 1 is accepted

Sort by
0
Missing User
answered on 20 Dec 2013, 03:35 PM
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 >>
0
Philipp
Top achievements
Rank 1
answered on 06 Jan 2014, 08:57 AM
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
0
Missing User
answered on 08 Jan 2014, 11:22 AM
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 >>
0
Philipp
Top achievements
Rank 1
answered on 08 Jan 2014, 01:37 PM
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
0
Missing User
answered on 09 Jan 2014, 03:51 PM
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 >>
0
Philipp
Top achievements
Rank 1
answered on 10 Jan 2014, 10:46 AM
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
0
Missing User
answered on 13 Jan 2014, 10:01 AM
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 >>
0
Philipp
Top achievements
Rank 1
answered on 14 Jan 2014, 08:11 AM
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
0
Accepted
Petya
Telerik team
answered on 16 Jan 2014, 03:20 PM
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 >>
Tags
RichTextBox
Asked by
Philipp
Top achievements
Rank 1
Answers by
Missing User
Philipp
Top achievements
Rank 1
Petya
Telerik team
Share this question
or