WPF TextBlock highlight certan parts based on search condition

Posted by Daniil Harik on Stack Overflow See other posts from Stack Overflow or by Daniil Harik
Published on 2009-04-15T13:40:14Z Indexed on 2010/05/06 20:38 UTC
Read the original article Hit count: 1144

Filed under:
|
|

Hello,

I have TextBlock that has Inlines dynamicly added to it (basically bunch of Run objects that are either italic or bold).

In my application I have search function.

I want to be able to highlight TextBlock's text that is in being searched for.

By highlighting I mean changing certain parts of TextBlock text's color (keeping in mind that it may highlight several different Run objects at a time).

I have tried this example http://blogs.microsoft.co.il/blogs/tamir/archive/2008/05/12/search-and-highlight-any-text-on-wpf-rendered-page.aspx

But it seams very unstable :(

Is there easy way to solve this problem?

© Stack Overflow or respective owner

Related posts about wpf

Related posts about textblock