C# – Change color in part of text in textblock


I need change color in code behind for part of text string..

My exaple:

textblock1.Text = string1 + string2 + string3;

String have dynamic values, and i want to string2 display after running the program in blue color and it must be defined in the code behind.

Its possible? Thank you!

Best Solution

That working

                        textblock1.Inlines.Add(new Run(string1));
                        textblock1.Inlines.Add(new Run(string2) { Foreground = Brushes.Blue });