Preserving Whitespaces Between XAML Tags

|

Filipe Fortes just blogs about Collapsed Spaces Around <Run /> issue in WPF, and his workaround is placing the text containing white spaces into the Text attribute, actually this is not a nice way of doing this, and you can actually twick the XAML parser to respect white spaces between XAML tags using the following trick:

<Pagexmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<
TextBlock>
<
Run xml:space="preserve">Hello XAML !</Run>
</
TextBlock>
</
Page>


For complete explanation on xml:space, you can refer to msdn documentation on Whitespace Processing in XAML.

0 comments: