Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Newline or carriage returns in Multibind StringFormat

So i've got the following:

<TextBlock.Text>
  <MultiBinding StringFormat="So and so will donate {0:C0}&#x0d;&#x0a;to {1}, bringing the&#x0d;&#x0a;total amount to {2:C0}.">
    <Binding Path="VisitorTotal" />
    <Binding Path="EventName" />
    <Binding Path="EventTotal" />
  </MultiBinding>
</TextBlock.Text>

I've tried &#x0d;&#x0a;, &#10;, \n, \\n, and various combinations thereto. Nothing will give me a newline. What's the deal?

like image 487
lose_the_grimm Avatar asked Apr 22 '13 21:04

lose_the_grimm


1 Answers

My preference is to use Environment.NewLine directly:

<MultiBinding StringFormat="So and so will donate {0:C0}{3}to {1}, bringing the{3}total amount to {2:C0}.">
  <Binding Path="VisitorTotal" />
  <Binding Path="EventName" />
  <Binding Path="EventTotal" />
  <Binding Source="{x:Static System:Environment.NewLine}"/>
</MultiBinding>

However, you'll also need to make sure the TextBlock.TextWrapping is set appropriately.

like image 89
Reed Copsey Avatar answered Nov 09 '22 02:11

Reed Copsey