用新行标记ContentStringFormat

时间:2015-09-26 07:05:18

标签: wpf label multibinding

我尝试在Label ContentStringFormat内添加新行:

Content="{Binding Path=(my:MyData.Files)}"
ContentStringFormat="{}Number of files:\n {0:#,0}"

有什么建议吗?

1 个答案:

答案 0 :(得分:1)

您不能在XAML代码中使用C#转义字符。对于XAML,还有其他可能性:

  • CR / LF 
的HEX表示(或仅换行
):

    ContentStringFormat="{}Number of files: 
 {0:#,0}"

  • 绑定到最初包含您需要的新行字符串的字符串

  • Environment.NewLine

    使用多重绑定
    <MultiBinding StringFormat="{}{0}{2}{1}" Mode="OneWay">
        <Binding Path="Property0" />
        <Binding Path="Property1" />
        <Binding Source="{x:Static System:Environment.NewLine}"/>
    </MultiBinding>
    
相关问题