0

I am using a TextBlock in the MainWindow.

I have a binding for it as below:

<TextBlock Name="LogMessageBox" DockPanel.Dock="Top" Text="{Binding BindingString} HorizontalAlignment="Center"/>

And in the code I have:

public string BindingString{ get; set; }

Now the problem I have is that I want to have colors for the text that I set the BindingString to:

BindingString = "This is a text String"

I want the output to be shown as

enter image description here

I can do this if I directly access the TextBlock as

LogMessageBox.Inlines.Add( new Run(message)) { Foreground = color });

and split the string message.

How can i do this by binding such that i can set color/format of different portion of string?

VinayChoudhary99
  • 846
  • 3
  • 13
  • 26

0 Answers0