是否可以将标签内容绑定(bind)到两个值。例如,我想要一个标签,其内容如下所示, UserName= Firstname, Lastname
其中名字和姓氏都是来自数据库的值。如果我要使用标签,我将绑定(bind)为 Content={Binding Firstname} 和 Content={Binding Lastname} 为别人。但我想要一个标签来显示两者。可能吗?
最佳答案
你可以这样做
<TextBlock>
<TextBlock.Text>
<MultiBinding StringFormat="{}{0}, {1}">
<Binding Path="firstName" />
<Binding Path="lastName"/>
</MultiBinding>
</TextBlock.Text>
</TextBlock>
关于c# - 绑定(bind)到两个值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2561253/