Вопрос

So I have a textblock that is receiving response text from a webclient

When I do this call in a browser I get nicely formatted responses

like this

enter image description here

but when I do this in code and push it into my textblock I get this (note that all the data is there just scrolled off of the screenshot)

enter image description here

Here is my textblock XAML

 <TextBlock xml:space="preserve"  Text="{Binding toolResponseText,Mode=TwoWay}"/>

I was hoping the space preserve line would have fixed this but it didn't.

Это было полезно?

Решение

No, xml:space = preserve is talking about whitespace within the XAML. It's not useful to you here.

The important point is that the browser is displaying it with a monospaced font, whereas you're using a variable-width font.

Try:

FontFamily="Consolas"

within your XAML. (If that font family doesn't change the appearance, find another one which does, and is still monospaced...)

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top