9

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?

4

1 回答 1

22

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.

于 2013-04-22T21:21:20.773 回答