How can I use tab and carriage return characters in a WPF XAML resource dictionary?
This doesn't work for me:
<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"
>
<system:String x:Key="test_Key">Tab doesnt work\tTest\rTest</system:String>
</ResourceDictionary>
when I retrieve this via FindResource("test_key"), both the tab and carriage return characters are removed.
The XAML parser uses whitespace normalisation (as per MSDN) if you want to avoid this add xml:space="preserve"
to your XML as such:
<system:String x:Key="test_Key" xml:space="preserve">Tab doesnt work	Test
Test</system:String>
Add newline like so 

and tab with 	
However this won't work unless you've turned off white-space normalization as J.Kommer suggests
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