Label ContentStringFormat with new line
Asked Answered
F

1

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 ?

Fissirostral answered 26/9, 2015 at 7:5 Comment(1)
What is the putput you're getting?Enthalpy
R
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>
    
Rectus answered 26/9, 2015 at 7:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.