我正在尝试执行以下操作:
但有多重绑定..这意味着我想要多个绑定..
所以我可以显示,例如,fullname作为firstname + lastname.
我们怎么做?
谢谢!
添加ItemTemplate如下:
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock>
<TextBlock.Text>
<MultiBinding StringFormat="{}{0}, {1}">
<Binding Path="LastName" />
<Binding Path="FirstName" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>
</DataTemplate>
</ComboBox.ItemTemplate>
Run Code Online (Sandbox Code Playgroud)
旁注:在实际代码中,我更经常使用Dean的方法,但这是MultiBinding的处理方式.
你的意思是这样简单吗
<ComboBox>
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock>
<Run Text="{Binding FirstName}" />
<Run Text=" " />
<Run Text="{Binding LastName}" />
</TextBlock>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
Run Code Online (Sandbox Code Playgroud)