chetan
chetan

Reputation: 381

WPF TextBlock Color for each Character

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

Upvotes: 27

Views: 49986

Answers (1)

Felice Pollano
Felice Pollano

Reputation: 33252

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

Upvotes: 64

Related Questions