如何在 WPF XAML 资源字典中使用制表符和回车符?
这对我不起作用:
<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>
当我通过 FindResource("test_key") 检索它时,制表符和回车符都被删除。
XAML 解析器使用空白规范化(根据MSDN http://msdn.microsoft.com/en-us/library/cc189036%28VS.95%29.aspx#whitespace)如果你想避免这个添加xml:space="preserve"
到你的XML:
<system:String x:Key="test_Key" xml:space="preserve">Tab doesnt work	Test
Test</system:String>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)