how to get each character of a textblock of different color in wpf?
WPF TextBlock Color for each Character
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:
How can I do this with MVVM? –
Liveried
Bind
TextBlock
text to a list of Runs
? –
Gestation @EmpereurAiman You can't bind
List<Run>
to Text
property of TextBlock
. But you can bind to Text
value of individual Run
. Try: https://mcmap.net/q/505522/-can-i-have-multiple-colors-in-a-single-textblock-in-wpf –
Dominion @EmpereurAiman After small research, found way to bind. Please refer this. https://mcmap.net/q/401776/-data-binding-the-textblock-inlines#9546372 –
Dominion
© 2022 - 2024 — McMap. All rights reserved.