0

I have such ListView

...
            <ListView
                x:Name="LVLog"
                ToolTip="Log of task(s) execution"
                Background="WhiteSmoke"
                HorizontalAlignment="Stretch"
                ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                VerticalAlignment="Stretch">
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding}" TextWrapping="Wrap"/>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>
...

There is how I set items

LVLog.Items.Add(message.Log);

And there ToString() method of object that I try to bind

public override string ToString() => string.Format("You are <span style='color:red'>{0}</span> km. in city <span style='color:red'>{1}</span> km.", 100, 136);

So, I expect to get 100 and 136 in red color, but actually I get this

enter image description here

What am I doing wrong? Why it does not format text as expected?

Sirop4ik
  • 4,543
  • 2
  • 54
  • 121

1 Answers1

1
<TextBlock TextWrapping="Wrap">
    <TextBlock Text="You are "/>
    <TextBlock Text="100" Foreground="Red"/>
    <TextBlock Text=" km. in city "/>
    <TextBlock Text="136" Foreground="Red"/>
    <TextBlock Text=" km."/>
</TextBlock>

html is not interpreted in TextBlock