My applications store all localized text in a string resource dictionary as suggested here http://msdn.microsoft.com/en-us/library/bb295251(VS.85).aspx
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib">
<!-- String resource that can be localized -->
<system:String x:Key="localizedMessage">en-US Message</system:String>
</ResourceDictionary>
My question is, how can I add a new line to a string resource and have it render correctly when it's used in a TextBlock.
Doing this inline works:
<TextBlock Name="test" Text="Line 1 Line 2"> </TextBlock>
However, using
in a string resource does not work. What's the best way to add a new line to a string resource?
UPDATE: updated answer - better option
The XAML parser normalized whitespace according to the following rules.
http://msdn.microsoft.com/en-us/library/cc189036(VS.95).aspx#whitespace
To instruct your sys:String
to preserve whitespace, apply xml:space="preserved
to it:
<sys:String x:Key="MyLocalizedString" xml:space="preserve">this is my resource</sys:String>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With