We’re developing a Windows Phone 7 app and have a TextBlock defined like so:
<TextBlock Text="{StaticResource MY_TEXT}" TextWrapping="Wrap" Style="{StaticResource SubHeadingStyle}"/>
We have a resource defined like so:
<system:String x:Key="MY_TEXT">This is the first line of text. This is the second line of text.</system:String>
We’ve tried all the ways we can think of to represent the line break in the XML, but whatever we try, it’s either completely ignored, or appears on screen within the TextBlock.
We’ve isolated the problem to the loading of the resource dictionary – if we read the string from the resource dictionary programmatically, the line break has been replaced by a space character (0x20). Conversely, if we put a line break character in the Text property of the TextBlock in the XAML, it does appear.
Is there any way we can get the line break to appear correctly in our TextBlock while still using bindings, and without writing code to modify the value?
You have to Preserve WhiteSpace