Collapsed Spaces Around

posted 2007-03-15

In response to my previous post, Nick asks:

Why are my spacings dropped when I have: <Run>NYC </Run> <Run> Hickster</Run>? This comes out NYCHickster

The space collapsing around Run can be a little tricky. The easiest thing to do if you're running into this issue is to use Run.Text, like so:

<Run Text="NYC " /><Run Text="Hickster" />

This technique works for inserting multiple spaces as well.

Update 3/18: Sheva points out a different method I had completely forgotten about -- using xml:space="preserve":
<Span xml:space="preserve"><Run>NYC</Run> <Run>Hickster</Run></Span>