简体   繁体   English

使用反斜杠 XAML 字符串类型的属性 MultiBinding.ConverterParameter 导致转义反斜杠

[英]Using backslashes XAML Attribute MultiBinding.ConverterParameter of type string results in escaped backslash

I'm using a string as a MultiBinding.ConverterParameter in a XAML-definition of a WPF-Window.我在 WPF 窗口的 XAML 定义中使用字符串作为 MultiBinding.ConverterParameter。 The converter concatenates multiple strings and uses the ConverterParameter as separator between them.转换器连接多个字符串并使用 ConverterParameter 作为它们之间的分隔符。 My problem is: when I want to use a CRLF as separator, the XAML-parser somehow escapes my backslashes.我的问题是:当我想使用 CRLF 作为分隔符时,XAML 解析器以某种方式转义了我的反斜杠。 So i get "\\r\\n" as parameter in the converter.所以我得到“\\r\\n”作为转换器中的参数。 I tried the following variants:我尝试了以下变体:

<MultiBinding Converter="{StaticResource mergeStringsMultiValueConverter}" >
    <MultiBinding.ConverterParameter>
        \r\n
    </MultiBinding.ConverterParameter>
    <Binding Path="ApprovalJoystick.ExtendedDisplayString" Mode="OneWay"/>
    <Binding Path="ApprovalJoystickActiveText" Mode="OneWay" />
</MultiBinding>

and

<MultiBinding Converter="{StaticResource mergeStringsMultiValueConverter}" ConverterParameter="\r\n">
    <Binding Path="ApprovalJoystick.ExtendedDisplayString" Mode="OneWay" />
    <Binding Path="ApprovalJoystickActiveText" Mode="OneWay" />
</MultiBinding>

Result is the same.结果是一样的。 Is the a way to get the CRLF as I wrote it in XAML (without escaping)?有没有办法像我在 XAML 中写的那样获取 CRLF(不转义)? Or can I write the linebreak in another way in XAML?或者我可以用另一种方式在 XAML 中写换行符吗?

Thank you.谢谢。

Try &#10;尝试&#10; , &#13; , &#13; or &#x0d;&#x0a;&#x0d;&#x0a; . . See Newline in string attribute .请参阅字符串属性中的换行符

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM