Multiline StringFormat中的换行符或回车符

时间:2013-04-22 21:17:37

标签: wpf xaml textblock multibinding

所以我有以下内容:

<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>

我已尝试&#x0d;&#x0a;&#10;\n\\n及其各种组合。什么都不会给我换行。这是什么交易?

1 个答案:

答案 0 :(得分:20)

我的偏好是直接使用Environment.NewLine

<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>

但是,您还需要确保TextBlock.TextWrapping设置正确。