0

I try to add new line inside Label ContentStringFormat:

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

Any suggestions ?

mark yer
  • 403
  • 6
  • 12

1 Answers1

2

You can't use C# escape characters in XAML code. For XAML there are other possibilities:

  • HEX represenation of CR/LF 
 (or just line feed 
):

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

  • Bind to string that initially contains new line charachters where you need them

  • Use multibinding with Environment.NewLine

    <MultiBinding StringFormat="{}{0}{2}{1}" Mode="OneWay">
        <Binding Path="Property0" />
        <Binding Path="Property1" />
        <Binding Source="{x:Static System:Environment.NewLine}"/>
    </MultiBinding>
    
Fabian N.
  • 3,807
  • 2
  • 23
  • 46
Mikhail Tumashenko
  • 1,683
  • 2
  • 21
  • 28