Selective coloring on dynamic TextBlock content in WPF

Posted by user326579 on Stack Overflow See other posts from Stack Overflow or by user326579
Published on 2010-04-27T06:11:05Z Indexed on 2010/04/27 6:13 UTC
Read the original article Hit count: 244

Filed under:
|

For selective coloring of static content the following suggestion works fine : http://stackoverflow.com/questions/2435880/is-it-possible-to-seletively-color-a-wrapping-textblock-in-silverlight-wpf

However my content will be generated at runtime. For ex. if the Content generated is : "A Quick Brown Fox" Then I need they string "Brown" to be in color Brown and "Fox" to be in color Red

The Keyword-Color list is fixed and available to me at runtime.

I have looked at the Advanced TextFormatting page on MSDN, but it is too complicated for me, also the sample in there does not compile :(

I am looking at creating a custom control which can do this for me. Let me know if anyone has any idea regarding how to go about this.

Thanks in advance.

© Stack Overflow or respective owner

Related posts about wpf

Related posts about textformatting