Question

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.

Était-ce utile?

La solution

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...)

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top