-3

In WPF (C#) Application, I want to color just the text in parentheses. Any help?
Ex: In this text:
The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', sometimes on purpose (injected humour and the like).

...the (injected humour and the like) must be colored in red.

Actually, I use RichTextBox to display the text..

DevIT
  • 17
  • 3

1 Answers1

0

You can achieve this using multiple Run elements inside a TextBlock control. The text will still flow within the bounds of the TextBlock. For example ...

<TextBlock MaxWidth="100" TextWrapping="Wrap">
    <Run Text="Standard Text " />
    <Run Foreground="Red" Text="red text" />
    <Run Text=" more standard text." />
</TextBlock>
Peregrine
  • 4,287
  • 3
  • 17
  • 34
  • Not actually what I need, I have dynamic text returned from Database, and programtically I have to color the text in parentheses. – DevIT Feb 09 '21 at 18:43