gpt4 book ai didi

wpf - 来自动态资源的 TextBlock 换行符

转载 作者:行者123 更新时间:2023-12-02 17:51:09 25 4
gpt4 key购买 nike

有一些资源标记( 类似于\r\n)

    <Application.Resources>
<system:String x:Key="key1">Line1&#x0d;&#x0a;Line2</system:String>
</Application.Resources>

对于主窗口:

   <Grid>
<TextBlock Text="{DynamicResource key1}"/>
<Grid>

但结果只有一行:“Line1 Line2”。怎么了?

最佳答案

只需像这样在您的字符串资源中设置 xml:space="preserve",它将按预期工作 -

<system:String xml:space="preserve" x:Key="key1">Line1&#x0d;&#x0a;Line2</system:String>

关于wpf - 来自动态资源的 TextBlock 换行符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8133579/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com