问题
I try to add new line inside Label ContentStringFormat
:
Content="{Binding Path=(my:MyData.Files)}"
ContentStringFormat="{}Number of files:\n {0:#,0}"
Any suggestions ?
回答1:
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>
来源:https://stackoverflow.com/questions/32794574/label-contentstringformat-with-new-line