WPF TextBlock Color for each Character

chetan picture chetan · Apr 4, 2011 · Viewed 38.7k times · Source

how to get each character of a textblock of different color in wpf?

Answer

Felice Pollano picture Felice Pollano · Apr 4, 2011

Use many different runs:

 <TextBlock FontSize="22">
            <Run Foreground="Gold">H</Run>
            <Run Foreground="Maroon">e</Run>
            <Run Foreground="Blue">l</Run>
            <Run Foreground="Orange">l</Run>
            <Run Foreground="Brown">o</Run>
        </TextBlock>

This produce the result: enter image description here