WPF TextBlock Color for each Character

Posted by Mittie Cheatwood on Monday, June 10, 2024

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

1 Answer

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

4

ncG1vNJzZmirpJawrLvVnqmfpJ%2Bse6S7zGiorp2jqbawutJobG5rZWt%2BenvWqZ1mrJWtwaO4zpyiZpufobyzecWoqWadkZi1bq%2FHmqmam6Savw%3D%3D