更新时间:2021-07-04 17:47:42
您可以使用 MultiBinding
结合 StringFormat
属性。用法类似于以下内容:
You can use a MultiBinding
combined with the StringFormat
property. Usage would resemble the following:
<TextBlock>
<TextBlock.Text>
<MultiBinding StringFormat="{}{0} + {1}">
<Binding Path="Name" />
<Binding Path="ID" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>
给定一个名称为 Foo
的值您在TextBlock中输出的ID为 1
的值将为 Foo + 1
。
Given a value of Name of Foo
and a value for ID of 1
you output in the TextBlock would be Foo + 1
.
注意:
仅在.NET 3.5 SP1和3.0 SP2或更高版本中支持。
Note:
that this is only supported in .NET 3.5 SP1 and 3.0 SP2 or later.